Selected: {{ select.properties.name }}
+
+ Selected:
+
+ {{ select.properties.name }}
+
+ {{ select.properties.citycode }}
+ {{ select.properties.context }}
+
+ {{ select.properties.id }}
+
-
- {{ name }} :
- {{ value }}
-
+
+
+
+
+
+
+
+
+
+
|
-
- {{ name }} :
- {{ value }}
+
+
+ {{ name }}
+
+ {{ value }}
+ |
+ select.properties: + {{ select }} ++
+ data: + {{ data }} ++
+ osm_data: + {{ osm_data }} +@@ -231,16 +275,17 @@ export default { return { data: [], osm_data: [], + all_tags: [], xml: nodeInfo.default.elements[0], mockEntreprise: resultsEntreprise.default, mockAddok: resultsAddok.default, select: {}, - searchQuery: 'tour montparnasse', + searchQuery: 'librairie interlignes', isFetching: false, } }, mounted() { - this.getAsyncData('tour eiffel') + this.getAsyncData(this.searchQuery) }, methods: { // You have to install and import debounce to use it, @@ -255,6 +300,8 @@ export default { .then(({ data }) => { console.log('data', data) this.data = [] + this.selectChoice(data.features[0]) + data.features.forEach((item) => this.data.push(item)) }) .catch((error) => { @@ -264,19 +311,6 @@ export default { .finally(() => { this.isFetching = false }) - // axios - // .get(`https://api.openstreetmap.org/api/0.6/node/6126513555`) - // .then(({ data }) => { - // console.log('data xml', data) - // this.xml = data.elements[0] - // }) - // .catch((error) => { - // this.xml = [] - // throw error - // }) - // .finally(() => { - // this.isFetching = false - // }) }, 500), selectChoice(option) { console.log('option', option) @@ -301,6 +335,7 @@ export default { .then(({ data }) => { console.log('OSM data', data) this.osm_data = data + this.mixTags() }) .catch((error) => { this.osm_data = [] @@ -313,6 +348,33 @@ export default { console.log('l url donnée n a pas de node ', url) } }, + + mixTags() { + if (this.osm_data && this.osm_data.elements[0]) { + for (const [key, value] of Object.entries( + this.osm_data.elements[0].tags + )) { + if (!this.all_tags[key]) { + this.createMissingKeyForMix(key) + } + this.all_tags[key].osm_data = value + } + } + if (this.select && this.osm_data.elements[0]) { + for (const [key, value] of Object.entries(this.select)) { + if (!this.all_tags[key]) { + this.createMissingKeyForMix(key) + } + this.all_tags[key].osm_data = value + } + } + }, + createMissingKeyForMix(key) { + this.all_tags[key] = { + osm_data: '', + addok_data: '', + } + }, }, }