0.0.2 • Published 4 years ago

@feendy/localization-address v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

forthebadge forthebadge

Introduction

Ce paquet contient un composant VueJS permettant d'afficher un champs, de saisir une adresse et d'autocompléter cette recherche.

Celui-ci utilise l'API adresse.data.gouv.fr permettant de récupérer des résultats uniquement en France de manière illimitée. (no rate limit)

npm.io

Vous pourrez ainsi récupérer de nombreuses informations comme :

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      2.372796,
      48.899609
    ]
  },
  "properties": {
    "label": "73 Rue Emile Bollaert 75019 Paris",
    "score": 0.8860401669600837,
    "housenumber": "73",
    "id": "75119_3212_00073",
    "type": "housenumber",
    "name": "73 Rue Emile Bollaert",
    "postcode": "75019",
    "citycode": "75119",
    "x": 654018.19,
    "y": 6866805.43,
    "city": "Paris",
    "district": "Paris 19e Arrondissement",
    "context": "75, Paris, Île-de-France",
    "importance": 0.7464418365609212,
    "street": "Rue Emile Bollaert"
  }
}

Installation

Actuellement le paquet n'est pas disponible sur NPM publiquement, il faudra modifier manuellement votre package.json afin de rajouter la dépendance de cette manière :

  "dependencies": {
    "@feendy/localization-address": "git+ssh://git@bitbucket.rib-server.fr:7999/feendy/localization-address.git"
  }

Veuillez disposer des accès nécessaires pour cloner le dépôt.

Utilisation

Vous pouvez utiliser ce composant de deux manières différentes.

Global

import LocalizationAddress from "@feendy/localization-address";
Vue.use(LocalizationAddress);

Locale (dans un composant)

import LocalizationAddress from "@feendy/localization-address";
components: {
	LocalizationAddress
},

<Address></Address>

Options

nametypedescriptionrequireddefault
waitStringMillisecondes avant que l'évènement submit se déclenchefalse500
attributesObjectAttributs à insérer pour le champs de recherchefalse{}
minLengthNumberLongueur minimum de caractères avant de déclencher une recherchefalse5
typeBoolean ou StringType de résultats souhaités (voir https://adresse.data.gouv.fr/api) : street, housenumber, locality, municipalityfalsehousenumber
limitNumber ou StringLimite de résultatsfalse5

Récupérer l'adresse sélectionnée (exemple de composant)

<template>
  <div>
    <label>Saisissez votre adresse : </label>
    <localization-address>
      :submit="submit" 
      :attributes="{autofocus: true}" 
      :wait="0"
      :min-length="3">
    </localization-address>
    <div v-if="suggestion">
      <label>Adresse</label> : {{ suggestion.properties.label }} <br>
      <a :href="'https://www.google.com/maps/place/' + suggestion.geometry.coordinates[1] + ',' + suggestion.geometry.coordinates[0]">Google Maps</a> <br>
      <label>Latitude</label> : {{ suggestion.geometry.coordinates[1] }} <br>
      <label>Longitude</label> : {{ suggestion.geometry.coordinates[0] }}
    </div>
  </div>
</template>

<script>
import LocalizationAddress from "@feendy/localization-address";

    export default {
        name: "Test",
        components: {
          LocalizationAddress
        },
        data () {
          return {
            suggestion: null,
          }
        },
        methods : {
          submit (suggestion) {
            this.suggestion = suggestion
          }
        }
    }
</script>

Développement

Un composant de test est disponible en utilisant la commande ci-dessous.

npm run test

Vous pouvez compiler le paquet avec la commande suivante.

npm run build

License

The MIT License (MIT) Copyright (c) 2019 Thibeault Chenu

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.0.2

4 years ago

0.0.1

4 years ago