diff --git a/components/admin/Geolocation.vue b/components/admin/Geolocation.vue index e5c1c67d..f55ea8ab 100644 --- a/components/admin/Geolocation.vue +++ b/components/admin/Geolocation.vue @@ -20,7 +20,7 @@ v-card persistent-hint :placeholder="geocoding_provider_default") - v-autocomplete.mb-6(v-model="geocoding_countrycodes" :disabled="geocoding_provider_type != null || geocoding_provider_type != 'Nominatim'" + v-autocomplete.mb-6(v-model="geocoding_countrycodes" :disabled="!(geocoding_provider_type === null || geocoding_provider_type === 'Nominatim')" @blur="save('geocoding_countrycodes', geocoding_countrycodes )" :label="$t('admin.geocoding_countrycodes')" :items="countries" diff --git a/components/admin/Places.vue b/components/admin/Places.vue index 63e14ee5..152fff48 100644 --- a/components/admin/Places.vue +++ b/components/admin/Places.vue @@ -68,7 +68,7 @@ import debounce from 'lodash/debounce' import get from 'lodash/get' export default { - data() { + data( {$store} ) { return { mdiPencil, mdiChevronRight, mdiChevronLeft, mdiMagnify, mdiEye, mdiMapSearch, mdiChevronDown, loading: false, @@ -161,19 +161,54 @@ export default { if (searchCoordinates.length) { this.loading = true const ret = await this.$axios.$get(`placeOSM/${this.geocoding_provider_type}/${searchCoordinates}`) - if (ret && ret.length) { - this.addressList = ret.map(v => { - const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name')) - const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : '' - return { - lat: v.lat, - lon: v.lon, - name, - address - } - }) - } else { - this.addressList = [] + if (this.geocoding_provider_type == "Nominatim") { + if (ret && ret.length) { + this.addressList = ret.map(v => { + const name = get(v.namedetails, 'alt_name', get(v.namedetails, 'name')) + const address = v.display_name ? v.display_name.replace(name, '').replace(/^, ?/, '') : '' + return { + class: v.class, + type: v.osm_type, + lat: v.lat, + lon: v.lon, + name, + address + } + }) + } else { + this.addressList = [] + } + } else if (this.geocoding_provider_type == "Photon") { + let photon_properties = ['housenumber', 'street', 'district', 'city', 'county', 'state', 'postcode', 'country'] + + if (ret) { + this.addressList = ret.features.map(v => { + let pre_name = v.properties.name || v.properties.street || '' + let pre_address = '' + + photon_properties.forEach((item, i) => { + let last = i == (photon_properties.length - 1) + if (v.properties[item] && !last) { + pre_address += v.properties[item]+', ' + } else if (v.properties[item]) { + pre_address += v.properties[item] + } + }); + + let name = pre_name + let address = pre_address + return { + class: v.properties.osm_key, + type: v.properties.osm_type, + lat: v.geometry.coordinates[1], + lon: v.geometry.coordinates[0], + name, + address + } + }) + } else { + this.addressList = [] + } } this.loading = false }