diff --git a/components/Map.vue b/components/Map.vue index 19ed9fe0..9846c9cc 100644 --- a/components/Map.vue +++ b/components/Map.vue @@ -19,8 +19,8 @@ client-only(placeholder='Loading...' ) .text-h6 v-icon(v-text='mdiMapMarker' ) nuxt-link.ml-2.p-name.text-decoration-none(v-text="event.place.name" :to='`/place/${event.place.name}`') - v-text.mx-2(v-text="`${event.place.address}`") - v-text.my-4(v-text="$t('common.getting_there')") + p.mx-2(v-text="`${event.place.address}`") + p.my-4(v-text="$t('common.getting_there')") v-row v-btn.ml-2(icon large :href="routeBy('foot')") v-icon(v-text='mdiWalk' color='white') @@ -32,87 +32,94 @@ client-only(placeholder='Loading...' ) diff --git a/components/WhereInput.vue b/components/WhereInput.vue index fcde2108..fa9ec92d 100644 --- a/components/WhereInput.vue +++ b/components/WhereInput.vue @@ -173,27 +173,24 @@ export default { this.$emit('input', { ...this.place }) }, searchCoordinates: debounce(async function(ev) { - this.loading = true const pre_searchCoordinates = ev.target.value.trim().toLowerCase() - // allow pasting coordinates lat/lon + // allow pasting coordinates lat/lon and lat,lon const searchCoordinates = pre_searchCoordinates.replace('/', ',') - // console.log(pre_searchCoordinates) - var regex_coords_comma = "-?[1-9][0-9]*(\\.[0-9]+)?,\\s*-?[1-9][0-9]*(\\.[0-9]+)?"; var regex_coords_slash = "-?[1-9][0-9]*(\\.[0-9]+)?/\\s*-?[1-9][0-9]*(\\.[0-9]+)?"; const setCoords = (v) => { - this.place.latitude = v[0].trim() - this.place.longitude = v[1].trim() - - if (this.place.latitude < -90 || this.place.latitude > 90) { - // non existent + const lat = v[0].trim() + const lon = v[1].trim() + // check coordinates are valid + if ((lat < 90 && lat > -90) + && (lon < 180 && lon > -180)) { + this.place.latitude = lat + this.place.longitude = lon + } else { + this.$root.$message("Non existent coordinates", { color: 'error' }) + return } - if (this.place.latitude < -180 || this.place.latitude > 180) { - // non existent - } - - this.loading = false; } if (pre_searchCoordinates.match(regex_coords_comma)) { @@ -208,10 +205,9 @@ export default { } if (searchCoordinates.length) { + this.loading = true this.detailsList = await this.$axios.$get(`placeNominatim/${searchCoordinates}`) - } - if (this.detailsList) { - this.loading = false; + this.loading = false } }, 300), } diff --git a/pages/event/_slug.vue b/pages/event/_slug.vue index b60bd31d..3cc1f86a 100644 --- a/pages/event/_slug.vue +++ b/pages/event/_slug.vue @@ -32,7 +32,7 @@ v-container#event.pa-0.pa-sm-2 v-icon(v-text='mdiMapMarker') nuxt-link.vcard.ml-2.p-name.text-decoration-none(itemprop="name" :to='`/place/${event.place.name}`') {{event.place && event.place.name}} .text-subtitle-1.p-street-address(itemprop='address') {{event.place && event.place.address}} - v-btn.mt-2(v-if='event.place.latitude && event.place.longitude' small v-text="$t('common.show_map')" :aria-label="$t('common.show_map')" @click="mapModal = true") + v-btn.mt-2(v-if='settings.allow_geolocation && event.place.latitude && event.place.longitude' small v-text="$t('common.show_map')" :aria-label="$t('common.show_map')" @click="mapModal = true") v-dialog(v-model='mapModal' :fullscreen='$vuetify.breakpoint.xsOnly' destroy-on-close) v-card Map(:event='event')