|
|
@@ -34,6 +34,24 @@ export default {
|
|
|
type: String,
|
|
|
required: false,
|
|
|
default: ''
|
|
|
+ },
|
|
|
+ type: {
|
|
|
+ type: String,
|
|
|
+ required: false,
|
|
|
+ default: 'housenumber',
|
|
|
+ validator (value) {
|
|
|
+ return ['housenumber', 'street', 'locality', 'municipality'].includes(value)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ limit: {
|
|
|
+ type: Number,
|
|
|
+ required: false,
|
|
|
+ default: 5
|
|
|
+ },
|
|
|
+ autocomplete: {
|
|
|
+ type: Boolean,
|
|
|
+ required: false,
|
|
|
+ default: true
|
|
|
}
|
|
|
},
|
|
|
data () {
|
|
|
@@ -66,7 +84,12 @@ export default {
|
|
|
this.loading = true
|
|
|
|
|
|
// Lazily load input items
|
|
|
- fetch('https://api-adresse.data.gouv.fr/search/?type=municipality&autocomplete=1&limit=5&q=' + val)
|
|
|
+ const apiUrl = 'https://api-adresse.data.gouv.fr/search/' +
|
|
|
+ `?type=${this.type}` +
|
|
|
+ `&autocomplete=${this.autocomplete ? 1 : 0}` +
|
|
|
+ `&limit=${this.limit}` +
|
|
|
+ `&q=${val}`
|
|
|
+ fetch(encodeURI(apiUrl))
|
|
|
.then(res => res.json())
|
|
|
.then(({ features }) => {
|
|
|
this.features = features
|