Final pre taxi
This commit is contained in:
@@ -191,7 +191,12 @@
|
||||
{% elif page == 'location' %}
|
||||
<h2>{{ t('location_story_title') }}</h2>
|
||||
<p>{{ t('location_story_text') }}</p>
|
||||
<div class="map-wrap map-consent" data-map-consent>
|
||||
<div
|
||||
class="map-wrap map-consent"
|
||||
data-map-consent
|
||||
data-route-denied="{{ t('route_location_denied') }}"
|
||||
data-route-unavailable="{{ t('route_location_unavailable') }}"
|
||||
>
|
||||
<button
|
||||
class="map-preview"
|
||||
type="button"
|
||||
@@ -219,6 +224,8 @@
|
||||
const src = {{ google_maps_embed_url|tojson }};
|
||||
const destination = {{ location_address|tojson }};
|
||||
const liveRouteLink = wrapper.querySelector("[data-location-route-live]");
|
||||
const deniedMsg = wrapper.dataset.routeDenied || "";
|
||||
const unavailableMsg = wrapper.dataset.routeUnavailable || "";
|
||||
let loaded = false;
|
||||
|
||||
const loadMap = () => {
|
||||
@@ -243,15 +250,10 @@
|
||||
if (liveRouteLink) {
|
||||
liveRouteLink.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
const fallback = liveRouteLink.getAttribute("href");
|
||||
const openFallback = () => {
|
||||
if (fallback) {
|
||||
window.open(fallback, "_blank", "noopener");
|
||||
}
|
||||
};
|
||||
|
||||
if (!navigator.geolocation) {
|
||||
openFallback();
|
||||
if (unavailableMsg) {
|
||||
window.alert(unavailableMsg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -266,7 +268,15 @@
|
||||
});
|
||||
window.open(`https://www.google.com/maps/dir/?${query.toString()}`, "_blank", "noopener");
|
||||
},
|
||||
() => openFallback(),
|
||||
(geoError) => {
|
||||
if (geoError && geoError.code === 1 && deniedMsg) {
|
||||
window.alert(deniedMsg);
|
||||
return;
|
||||
}
|
||||
if (unavailableMsg) {
|
||||
window.alert(unavailableMsg);
|
||||
}
|
||||
},
|
||||
{ enableHighAccuracy: true, timeout: 4500, maximumAge: 120000 }
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user