From 8efeda085a86c326e5d548ec6e3ca903136a2bac Mon Sep 17 00:00:00 2001 From: sedum Date: Mon, 20 Feb 2023 07:05:21 +0100 Subject: [PATCH] continue refactor of geocoding services, improved locale, fixes on mapEdit --- components/MapEdit.vue | 4 +- components/WhereInput.vue | 22 +- components/WhereInputAdvanced.vue | 60 +- components/admin/Geolocation.vue | 2 +- components/admin/Places.vue | 51 +- locales/en.json | 11 +- pages/event/_slug.vue | 26 +- server/helpers/geolocation.js | 987 ------------------------- server/helpers/geolocation/index.js | 25 +- server/services/geocoding/nominatim.js | 14 +- server/services/geocoding/photon.js | 15 +- 11 files changed, 117 insertions(+), 1100 deletions(-) delete mode 100644 server/helpers/geolocation.js diff --git a/components/MapEdit.vue b/components/MapEdit.vue index e6cf1bec..c60b2d39 100644 --- a/components/MapEdit.vue +++ b/components/MapEdit.vue @@ -54,7 +54,9 @@ export default { }); setTimeout(() => { - this.$refs.map.mapObject.invalidateSize(); + if (this.$refs.map && this.$refs.map.mapObject ) { + this.$refs.map.mapObject.invalidateSize(); + } }, 200); } } diff --git a/components/WhereInput.vue b/components/WhereInput.vue index 0722f0a6..481889b8 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -28,7 +28,7 @@ v-row.mb-4 v-combobox.mr-4(v-model="virtualLocations" v-if="settings.allow_event_only_online && value.name === 'online'" :prepend-icon='mdiLink' :hint="$t('event.online_locations_help')" - :label="$t('event.online_event_urls')" + :label="$t('event.online_locations_url')" clearable chips small-chips multiple deletable-chips hide-no-data hide-selected persistent-hint :delimiters="[',', ';', '; ']" :items="virtualLocations" @@ -55,7 +55,7 @@ v-row.mb-4 v-dialog(v-model='whereInputAdvancedDialog' :key="whereAdvancedId" destroy-on-close max-width='700px' :fullscreen='$vuetify.breakpoint.xsOnly' dense) WhereInputAdvanced(ref='whereAdvanced' :place.sync='value' :event='event' @close='whereInputAdvancedDialog = false && this.$refs.address.blur()' :virtualLocations.sync="virtualLocations" - :online_event_only_value.sync='online_event_only' + :event_only_online_value.sync='event_only_online' @update:onlineEvent="changeOnlineEvent" @update:virtualLocations="selectLocations" ) @@ -86,7 +86,7 @@ export default { whereInputAdvancedDialog: false, hideWhereInputAdvancedDialogButton: !$store.state.settings.allow_event_also_online && !$store.state.settings.allow_geolocation, virtualLocations: this.event.locations || [], - online_event_only: (this.value.name === 'online') ? true : false, + event_only_online: (this.value.name === 'online') ? true : false, whereAdvancedId: 1 } }, @@ -135,7 +135,7 @@ export default { }, 200), selectPlace (p) { // force online events under place: online address: online - this.online_event_only = false + this.event_only_online = false this.place.isNew = false this.whereAdvancedId++ @@ -150,7 +150,7 @@ export default { } this.place.id = p.id if (this.settings.allow_event_only_online && this.place.name === 'online') { - this.online_event_only = true + this.event_only_online = true } this.disableAddress = true } else { // this is a new place @@ -184,6 +184,10 @@ export default { }, selectLocations () { this.event.locations = [] + // Insert up to 3 online location: the main one and 2 fallback + if (this.virtualLocations && this.virtualLocations.length > 3) { + this.$nextTick(() => this.virtualLocations.pop()) + } this.virtualLocations && this.virtualLocations.forEach((item, i) => { if (!item.startsWith('http')) { this.virtualLocations[i] = `https://${item}` @@ -192,10 +196,10 @@ export default { }) }, changeOnlineEvent(v) { - this.online_event_only = v - // console.log(this.online_event_only) - if (this.online_event_only) { this.place.name = this.place.address = 'online' } - if (!this.online_event_only) { this.place.name = this.place.address = '' } + this.event_only_online = v + // console.log(this.event_only_online) + if (this.event_only_online) { this.place.name = this.place.address = 'online' } + if (!this.event_only_online) { this.place.name = this.place.address = '' } this.place.latitude = null this.place.longitude = null diff --git a/components/WhereInputAdvanced.vue b/components/WhereInputAdvanced.vue index e50a42b5..3f396629 100644 --- a/components/WhereInputAdvanced.vue +++ b/components/WhereInputAdvanced.vue @@ -4,11 +4,11 @@ v-card v-card-subtitle {{ $t('event.where_advanced_options_description') }} v-card-text(v-if='settings.allow_event_also_online') - v-switch.mt-0.mb-4(v-model='online_event_only_update' + v-switch.mt-0.mb-4(v-model='event_only_online_update' v-if='settings.allow_event_only_online' persistent-hint :label="$t('event.event_only_online_label')" - :hint="$t('event.online_event_only_help')") + :hint="$t('event.event_only_online_help')") v-combobox.mt-0.mb-0.mr-4.my-5(v-model="virtualLocations_update" v-if="place.name !== 'online' && settings.allow_event_also_online" @@ -69,19 +69,19 @@ v-card diff --git a/locales/en.json b/locales/en.json index 4892d357..7176098f 100644 --- a/locales/en.json +++ b/locales/en.json @@ -184,13 +184,12 @@ "download_flyer": "Download flyer", "where_advanced_options": "Place - Advanced options", "where_advanced_options_description": "Define here additional place properties to the event", - "online_event_only": "Online event", + "event_only_online": "Online event", "event_only_online_label": "Event only online", - "online_event_only_help": "For online-only event, the default place name 'online' is applied", - "online_event_too": "Partecipate remotely", - "online_event_label": "Online locations", - "online_event_urls": "Online locations", - "online_event_fallback_urls": "Fallback links", + "event_only_online_help": "For online-only event, the default place name 'online' is applied", + "event_also_online": "Partecipate remotely", + "online_locations_url": "Online locations", + "online_locations_fallback_urls": "Fallback links", "additional_online_locations": "Additional online locations", "additional_online_locations_help": "Online locations, for instance a url to a videconference room", "address_geocoded_disclaimer": "Didn't you found the address or housenumber you are looking for? The OpenStreetMap project is open to contributions. If you have Android, we recommend StreetComplete ", diff --git a/pages/event/_slug.vue b/pages/event/_slug.vue index 96f32f49..0ee8b377 100644 --- a/pages/event/_slug.vue +++ b/pages/event/_slug.vue @@ -38,19 +38,19 @@ v-container#event.pa-0.pa-sm-2 //- online events v-divider(v-if='onlineSectionEnabled && event.locations && event.locations.length') - v-card(v-if='onlineSectionEnabled && event.locations && event.locations.length') - v-card-text.text-caption.pb-0(v-text="event.place.name === 'online' && $t('event.online_event_only') || $t('event.online_event_too') ") - v-list-item(target='_blank' :href='`${event.locations[0]}`') - v-list-item-icon - v-icon.my-auto(v-text='mdiMonitorAccount') - v-list-item-content.py-0 - v-list-item-title.text-caption(v-text='`${event.locations[0]}`') - v-card.pb-2(v-if='onlineSectionEnabled && event.locations && event.locations.length > 1') - v-card-text.text-caption.pt-0.pb-0(v-text="$t('event.online_event_fallback_urls')") - v-list-item - v-list-item-content - v-chip(v-for='(item, index) in event.locations' v-if="index > 0" target='_blank' :href="`${item}`" - v-bind:key="index" small label v-text="`${item}`" outlined ) + v-card-text.text-caption.pb-0(v-if='onlineSectionEnabled && event.locations && event.locations.length' + v-text="event.place.name === 'online' && $t('event.event_only_online') || $t('event.event_also_online') ") + v-list-item(target='_blank' :href='`${event.locations[0]}`') + v-list-item-icon + v-icon.my-auto(v-text='mdiMonitorAccount') + v-list-item-content.py-0 + v-list-item-title.text-caption(v-text='`${event.locations[0]}`') + v-card-text.text-caption.pt-0.pb-0(v-if='onlineSectionEnabled && event.locations && event.locations.length > 1' + v-text="$t('event.online_locations_fallback_urls')") + v-list-item + v-list-item-content + v-chip(v-for='(item, index) in event.locations' v-if="index > 0" target='_blank' :href="`${item}`" + v-bind:key="index" small label v-text="`${item}`" outlined ) v-divider //- info & actions diff --git a/server/helpers/geolocation.js b/server/helpers/geolocation.js deleted file mode 100644 index e1edaa88..00000000 --- a/server/helpers/geolocation.js +++ /dev/null @@ -1,987 +0,0 @@ -// Iso conversions - -var isoCountries = [ - { - "code": "af", - "name": "Afghanistan" - }, - { - "code": "ax", - "name": "Aland Islands" - }, - { - "code": "al", - "name": "Albania" - }, - { - "code": "dz", - "name": "Algeria" - }, - { - "code": "as", - "name": "American Samoa" - }, - { - "code": "ad", - "name": "Andorra" - }, - { - "code": "ao", - "name": "Angola" - }, - { - "code": "ai", - "name": "Anguilla" - }, - { - "code": "aq", - "name": "Antarctica" - }, - { - "code": "ag", - "name": "Antigua And Barbuda" - }, - { - "code": "ar", - "name": "Argentina" - }, - { - "code": "am", - "name": "Armenia" - }, - { - "code": "aw", - "name": "Aruba" - }, - { - "code": "au", - "name": "Australia" - }, - { - "code": "at", - "name": "Austria" - }, - { - "code": "az", - "name": "Azerbaijan" - }, - { - "code": "bs", - "name": "Bahamas" - }, - { - "code": "bh", - "name": "Bahrain" - }, - { - "code": "bd", - "name": "Bangladesh" - }, - { - "code": "bb", - "name": "Barbados" - }, - { - "code": "by", - "name": "Belarus" - }, - { - "code": "be", - "name": "Belgium" - }, - { - "code": "bz", - "name": "Belize" - }, - { - "code": "bj", - "name": "Benin" - }, - { - "code": "bm", - "name": "Bermuda" - }, - { - "code": "bt", - "name": "Bhutan" - }, - { - "code": "bo", - "name": "Bolivia" - }, - { - "code": "ba", - "name": "Bosnia And Herzegovina" - }, - { - "code": "bw", - "name": "Botswana" - }, - { - "code": "bv", - "name": "Bouvet Island" - }, - { - "code": "br", - "name": "Brazil" - }, - { - "code": "io", - "name": "British Indian Ocean Territory" - }, - { - "code": "bn", - "name": "Brunei Darussalam" - }, - { - "code": "bg", - "name": "Bulgaria" - }, - { - "code": "bf", - "name": "Burkina Faso" - }, - { - "code": "bi", - "name": "Burundi" - }, - { - "code": "kh", - "name": "Cambodia" - }, - { - "code": "cm", - "name": "Cameroon" - }, - { - "code": "ca", - "name": "Canada" - }, - { - "code": "cv", - "name": "Cape Verde" - }, - { - "code": "ky", - "name": "Cayman Islands" - }, - { - "code": "cf", - "name": "Central African Republic" - }, - { - "code": "td", - "name": "Chad" - }, - { - "code": "cl", - "name": "Chile" - }, - { - "code": "cn", - "name": "China" - }, - { - "code": "cx", - "name": "Christmas Island" - }, - { - "code": "cc", - "name": "Cocos (Keeling) Islands" - }, - { - "code": "co", - "name": "Colombia" - }, - { - "code": "km", - "name": "Comoros" - }, - { - "code": "cg", - "name": "Congo" - }, - { - "code": "cd", - "name": "Congo, Democratic Republic" - }, - { - "code": "ck", - "name": "Cook Islands" - }, - { - "code": "cr", - "name": "Costa Rica" - }, - { - "code": "ci", - "name": "Cote D'Ivoire" - }, - { - "code": "hr", - "name": "Croatia" - }, - { - "code": "cu", - "name": "Cuba" - }, - { - "code": "cy", - "name": "Cyprus" - }, - { - "code": "cz", - "name": "Czech Republic" - }, - { - "code": "dk", - "name": "Denmark" - }, - { - "code": "dj", - "name": "Djibouti" - }, - { - "code": "dm", - "name": "Dominica" - }, - { - "code": "do", - "name": "Dominican Republic" - }, - { - "code": "ec", - "name": "Ecuador" - }, - { - "code": "eg", - "name": "Egypt" - }, - { - "code": "sv", - "name": "El Salvador" - }, - { - "code": "gq", - "name": "Equatorial Guinea" - }, - { - "code": "er", - "name": "Eritrea" - }, - { - "code": "ee", - "name": "Estonia" - }, - { - "code": "et", - "name": "Ethiopia" - }, - { - "code": "fk", - "name": "Falkland Islands (Malvinas)" - }, - { - "code": "fo", - "name": "Faroe Islands" - }, - { - "code": "fj", - "name": "Fiji" - }, - { - "code": "fi", - "name": "Finland" - }, - { - "code": "fr", - "name": "France" - }, - { - "code": "gf", - "name": "French Guiana" - }, - { - "code": "pf", - "name": "French Polynesia" - }, - { - "code": "tf", - "name": "French Southern Territories" - }, - { - "code": "ga", - "name": "Gabon" - }, - { - "code": "gm", - "name": "Gambia" - }, - { - "code": "ge", - "name": "Georgia" - }, - { - "code": "de", - "name": "Germany" - }, - { - "code": "gh", - "name": "Ghana" - }, - { - "code": "gi", - "name": "Gibraltar" - }, - { - "code": "gr", - "name": "Greece" - }, - { - "code": "gl", - "name": "Greenland" - }, - { - "code": "gd", - "name": "Grenada" - }, - { - "code": "gp", - "name": "Guadeloupe" - }, - { - "code": "gu", - "name": "Guam" - }, - { - "code": "gt", - "name": "Guatemala" - }, - { - "code": "gg", - "name": "Guernsey" - }, - { - "code": "gn", - "name": "Guinea" - }, - { - "code": "gw", - "name": "Guinea-Bissau" - }, - { - "code": "gy", - "name": "Guyana" - }, - { - "code": "ht", - "name": "Haiti" - }, - { - "code": "hm", - "name": "Heard Island & Mcdonald Islands" - }, - { - "code": "va", - "name": "Holy See (Vatican City State)" - }, - { - "code": "hn", - "name": "Honduras" - }, - { - "code": "hk", - "name": "Hong Kong" - }, - { - "code": "hu", - "name": "Hungary" - }, - { - "code": "is", - "name": "Iceland" - }, - { - "code": "in", - "name": "India" - }, - { - "code": "id", - "name": "Indonesia" - }, - { - "code": "ir", - "name": "Iran, Islamic Republic Of" - }, - { - "code": "iq", - "name": "Iraq" - }, - { - "code": "ie", - "name": "Ireland" - }, - { - "code": "im", - "name": "Isle Of Man" - }, - { - "code": "il", - "name": "Israel" - }, - { - "code": "it", - "name": "Italy" - }, - { - "code": "jm", - "name": "Jamaica" - }, - { - "code": "jp", - "name": "Japan" - }, - { - "code": "je", - "name": "Jersey" - }, - { - "code": "jo", - "name": "Jordan" - }, - { - "code": "kz", - "name": "Kazakhstan" - }, - { - "code": "ke", - "name": "Kenya" - }, - { - "code": "ki", - "name": "Kiribati" - }, - { - "code": "kr", - "name": "Korea" - }, - { - "code": "kw", - "name": "Kuwait" - }, - { - "code": "kg", - "name": "Kyrgyzstan" - }, - { - "code": "la", - "name": "Lao People's Democratic Republic" - }, - { - "code": "lv", - "name": "Latvia" - }, - { - "code": "lb", - "name": "Lebanon" - }, - { - "code": "ls", - "name": "Lesotho" - }, - { - "code": "lr", - "name": "Liberia" - }, - { - "code": "ly", - "name": "Libyan Arab Jamahiriya" - }, - { - "code": "li", - "name": "Liechtenstein" - }, - { - "code": "lt", - "name": "Lithuania" - }, - { - "code": "lu", - "name": "Luxembourg" - }, - { - "code": "mo", - "name": "Macao" - }, - { - "code": "mk", - "name": "Macedonia" - }, - { - "code": "mg", - "name": "Madagascar" - }, - { - "code": "mw", - "name": "Malawi" - }, - { - "code": "my", - "name": "Malaysia" - }, - { - "code": "mv", - "name": "Maldives" - }, - { - "code": "ml", - "name": "Mali" - }, - { - "code": "mt", - "name": "Malta" - }, - { - "code": "mh", - "name": "Marshall Islands" - }, - { - "code": "mq", - "name": "Martinique" - }, - { - "code": "mr", - "name": "Mauritania" - }, - { - "code": "mu", - "name": "Mauritius" - }, - { - "code": "yt", - "name": "Mayotte" - }, - { - "code": "mx", - "name": "Mexico" - }, - { - "code": "fm", - "name": "Micronesia, Federated States Of" - }, - { - "code": "md", - "name": "Moldova" - }, - { - "code": "mc", - "name": "Monaco" - }, - { - "code": "mn", - "name": "Mongolia" - }, - { - "code": "me", - "name": "Montenegro" - }, - { - "code": "ms", - "name": "Montserrat" - }, - { - "code": "ma", - "name": "Morocco" - }, - { - "code": "mz", - "name": "Mozambique" - }, - { - "code": "mm", - "name": "Myanmar" - }, - { - "code": "na", - "name": "Namibia" - }, - { - "code": "nr", - "name": "Nauru" - }, - { - "code": "np", - "name": "Nepal" - }, - { - "code": "nl", - "name": "Netherlands" - }, - { - "code": "an", - "name": "Netherlands Antilles" - }, - { - "code": "nc", - "name": "New Caledonia" - }, - { - "code": "nz", - "name": "New Zealand" - }, - { - "code": "ni", - "name": "Nicaragua" - }, - { - "code": "ne", - "name": "Niger" - }, - { - "code": "ng", - "name": "Nigeria" - }, - { - "code": "nu", - "name": "Niue" - }, - { - "code": "nf", - "name": "Norfolk Island" - }, - { - "code": "mp", - "name": "Northern Mariana Islands" - }, - { - "code": "no", - "name": "Norway" - }, - { - "code": "om", - "name": "Oman" - }, - { - "code": "pk", - "name": "Pakistan" - }, - { - "code": "pw", - "name": "Palau" - }, - { - "code": "ps", - "name": "Palestinian Territory, Occupied" - }, - { - "code": "pa", - "name": "Panama" - }, - { - "code": "pg", - "name": "Papua New Guinea" - }, - { - "code": "py", - "name": "Paraguay" - }, - { - "code": "pe", - "name": "Peru" - }, - { - "code": "ph", - "name": "Philippines" - }, - { - "code": "pn", - "name": "Pitcairn" - }, - { - "code": "pl", - "name": "Poland" - }, - { - "code": "pt", - "name": "Portugal" - }, - { - "code": "pr", - "name": "Puerto Rico" - }, - { - "code": "qa", - "name": "Qatar" - }, - { - "code": "re", - "name": "Reunion" - }, - { - "code": "ro", - "name": "Romania" - }, - { - "code": "ru", - "name": "Russian Federation" - }, - { - "code": "rw", - "name": "Rwanda" - }, - { - "code": "bl", - "name": "Saint Barthelemy" - }, - { - "code": "sh", - "name": "Saint Helena" - }, - { - "code": "kn", - "name": "Saint Kitts And Nevis" - }, - { - "code": "lc", - "name": "Saint Lucia" - }, - { - "code": "mf", - "name": "Saint Martin" - }, - { - "code": "pm", - "name": "Saint Pierre And Miquelon" - }, - { - "code": "vc", - "name": "Saint Vincent And Grenadines" - }, - { - "code": "ws", - "name": "Samoa" - }, - { - "code": "sm", - "name": "San Marino" - }, - { - "code": "st", - "name": "Sao Tome And Principe" - }, - { - "code": "sa", - "name": "Saudi Arabia" - }, - { - "code": "sn", - "name": "Senegal" - }, - { - "code": "rs", - "name": "Serbia" - }, - { - "code": "sc", - "name": "Seychelles" - }, - { - "code": "sl", - "name": "Sierra Leone" - }, - { - "code": "sg", - "name": "Singapore" - }, - { - "code": "sk", - "name": "Slovakia" - }, - { - "code": "si", - "name": "Slovenia" - }, - { - "code": "sb", - "name": "Solomon Islands" - }, - { - "code": "so", - "name": "Somalia" - }, - { - "code": "za", - "name": "South Africa" - }, - { - "code": "gs", - "name": "South Georgia And Sandwich Isl." - }, - { - "code": "es", - "name": "Spain" - }, - { - "code": "lk", - "name": "Sri Lanka" - }, - { - "code": "sd", - "name": "Sudan" - }, - { - "code": "sr", - "name": "Suriname" - }, - { - "code": "sj", - "name": "Svalbard And Jan Mayen" - }, - { - "code": "sz", - "name": "Swaziland" - }, - { - "code": "se", - "name": "Sweden" - }, - { - "code": "ch", - "name": "Switzerland" - }, - { - "code": "sy", - "name": "Syrian Arab Republic" - }, - { - "code": "tw", - "name": "Taiwan" - }, - { - "code": "tj", - "name": "Tajikistan" - }, - { - "code": "tz", - "name": "Tanzania" - }, - { - "code": "th", - "name": "Thailand" - }, - { - "code": "tl", - "name": "Timor-Leste" - }, - { - "code": "tg", - "name": "Togo" - }, - { - "code": "tk", - "name": "Tokelau" - }, - { - "code": "to", - "name": "Tonga" - }, - { - "code": "tt", - "name": "Trinidad And Tobago" - }, - { - "code": "tn", - "name": "Tunisia" - }, - { - "code": "tr", - "name": "Turkey" - }, - { - "code": "tm", - "name": "Turkmenistan" - }, - { - "code": "tc", - "name": "Turks And Caicos Islands" - }, - { - "code": "tv", - "name": "Tuvalu" - }, - { - "code": "ug", - "name": "Uganda" - }, - { - "code": "ua", - "name": "Ukraine" - }, - { - "code": "ae", - "name": "United Arab Emirates" - }, - { - "code": "gb", - "name": "United Kingdom" - }, - { - "code": "us", - "name": "United States" - }, - { - "code": "um", - "name": "United States Outlying Islands" - }, - { - "code": "uy", - "name": "Uruguay" - }, - { - "code": "uz", - "name": "Uzbekistan" - }, - { - "code": "vu", - "name": "Vanuatu" - }, - { - "code": "ve", - "name": "Venezuela" - }, - { - "code": "vn", - "name": "Viet Nam" - }, - { - "code": "vg", - "name": "Virgin Islands, British" - }, - { - "code": "vi", - "name": "Virgin Islands, U.S." - }, - { - "code": "wf", - "name": "Wallis And Futuna" - }, - { - "code": "eh", - "name": "Western Sahara" - }, - { - "code": "ye", - "name": "Yemen" - }, - { - "code": "zm", - "name": "Zambia" - }, - { - "code": "zw", - "name": "Zimbabwe" - } - ] - - -module.exports = { isoCountries } diff --git a/server/helpers/geolocation/index.js b/server/helpers/geolocation/index.js index 412083ec..f8beaf3d 100644 --- a/server/helpers/geolocation/index.js +++ b/server/helpers/geolocation/index.js @@ -1,17 +1,18 @@ -const isoCountries = require('./isoCountries') const nominatim = require('../../../server/services/geocoding/nominatim') const photon = require('../../../server/services/geocoding/photon') -// const geocodingProviders = [ nominatim, photon ] +const geocodingProviders = [ nominatim, photon ] -// const geolocation = { -// getGeocodingProvider(providerName) { -// geocodingProviders.forEach((item) => { -// if (item.commonName === settings.geocoding_provider_type) { -// return item -// } -// }) -// } -// } +const geolocation = { + getGeocodingProvider(providerName) { + let geocodingProvider + geocodingProviders.forEach((item) => { + if (item.commonName === providerName) { + geocodingProvider = item + } + }) + return geocodingProvider + } +} -// module.exports = geolocation \ No newline at end of file +module.exports = geolocation \ No newline at end of file diff --git a/server/services/geocoding/nominatim.js b/server/services/geocoding/nominatim.js index b6050bd6..ffac8693 100644 --- a/server/services/geocoding/nominatim.js +++ b/server/services/geocoding/nominatim.js @@ -24,7 +24,7 @@ const nominatim = { } }, - /* + /** * Icons to nominatim `osm_type` and `class` conversion */ searchIcons_nominatim_osm_type: { @@ -33,10 +33,18 @@ const nominatim = { node: 'mdiMapMarker', relation: 'mdiCityVariant', }, - searchIcons_nominatim_class: { - mdiHome: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'] + searchIcons_nominatim_class: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'], + + loadResultIcon (item) { + if (this.searchIcons_nominatim_class.includes(item.class)) { + return 'mdiHome' + } + return this.searchIcons_nominatim_osm_type[item.type] }, + /** + * Map results from provider + */ filterNameFromAddress: ['place', 'amenity', 'shop', 'tourism', 'leisure', 'building'], mapQueryResults (ret, addressList = []) { diff --git a/server/services/geocoding/photon.js b/server/services/geocoding/photon.js index 4170c543..dce5e9a5 100644 --- a/server/services/geocoding/photon.js +++ b/server/services/geocoding/photon.js @@ -18,7 +18,7 @@ const photon = { } }, - /* + /** * Icons to nominatim `osm_type` and `class` conversion */ searchIcons_nominatim_osm_type: { @@ -26,11 +26,18 @@ const photon = { 'N': 'mdiMapMarker', 'R': 'mdiCityVariant', }, - searchIcons_nominatim_class: { - mdiHome: ['amenity', 'shop', 'tourism', 'leisure', 'building'], + searchIcons_nominatim_class: ['amenity', 'shop', 'tourism', 'leisure', 'building'], + + loadResultIcon (item) { + if (this.searchIcons_nominatim_class.includes(item.class)) { + return 'mdiHome' + } + return this.searchIcons_nominatim_osm_type[item.type] }, - + /** + * Map results from provider + */ fullAddressMapping: ['housenumber', 'street', 'locality', 'district', 'city', 'county', 'state', 'postcode', 'country'], mapQueryResults(ret, addressList = []) {