2021-10-10 16:25:50 +02:00
|
|
|
<template>
|
2022-11-04 18:17:30 +01:00
|
|
|
<div class="">
|
|
|
|
<div class="text-end">
|
|
|
|
<button @click="emit('close')">
|
|
|
|
<Close />
|
|
|
|
<span class="sr-only">{{ t("Close map") }}</span>
|
|
|
|
</button>
|
2021-10-10 16:25:50 +02:00
|
|
|
</div>
|
2022-11-04 18:17:30 +01:00
|
|
|
<section class="map">
|
|
|
|
<map-leaflet
|
|
|
|
v-if="physicalAddress?.geom"
|
|
|
|
:coords="physicalAddress.geom"
|
|
|
|
:marker="{
|
|
|
|
text: physicalAddress.fullName,
|
|
|
|
icon: physicalAddress.poiInfos.poiIcon.icon,
|
|
|
|
}"
|
|
|
|
/>
|
|
|
|
</section>
|
|
|
|
<section class="flex flex-col items-center mt-4">
|
|
|
|
<p v-if="physicalAddress?.fullName" class="flex gap-2 text-xl font-bold">
|
|
|
|
<MapMarker />
|
|
|
|
{{ physicalAddress.fullName }}
|
|
|
|
</p>
|
|
|
|
<p class="mt-4">{{ t("Getting there") }}</p>
|
|
|
|
<div
|
|
|
|
class="flex gap-2"
|
|
|
|
v-if="
|
|
|
|
addressLinkToRouteByCar ||
|
|
|
|
addressLinkToRouteByBike ||
|
|
|
|
addressLinkToRouteByFeet
|
|
|
|
"
|
|
|
|
>
|
|
|
|
<o-button
|
|
|
|
tag="a"
|
|
|
|
target="_blank"
|
|
|
|
v-if="addressLinkToRouteByFeet"
|
|
|
|
:href="addressLinkToRouteByFeet"
|
|
|
|
>
|
|
|
|
<Walk />
|
|
|
|
<span class="sr-only">{{ t("On foot") }}</span>
|
|
|
|
</o-button>
|
|
|
|
<o-button
|
|
|
|
tag="a"
|
|
|
|
target="_blank"
|
|
|
|
v-if="addressLinkToRouteByBike"
|
|
|
|
:href="addressLinkToRouteByBike"
|
|
|
|
>
|
|
|
|
<Bike />
|
|
|
|
<span class="sr-only">{{ t("By bike") }}</span>
|
|
|
|
</o-button>
|
|
|
|
<o-button
|
|
|
|
tag="a"
|
|
|
|
target="_blank"
|
|
|
|
v-if="addressLinkToRouteByTransit"
|
|
|
|
:href="addressLinkToRouteByTransit"
|
|
|
|
>
|
|
|
|
<Bus />
|
|
|
|
<span class="sr-only">{{ t("By transit") }}</span>
|
|
|
|
</o-button>
|
|
|
|
<o-button
|
|
|
|
tag="a"
|
|
|
|
target="_blank"
|
|
|
|
v-if="addressLinkToRouteByCar"
|
|
|
|
:href="addressLinkToRouteByCar"
|
|
|
|
>
|
|
|
|
<Car />
|
|
|
|
<span class="sr-only">{{ t("By car") }}</span>
|
|
|
|
</o-button>
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-10-10 16:25:50 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
2022-07-12 10:55:28 +02:00
|
|
|
<script lang="ts" setup>
|
2021-10-10 16:25:50 +02:00
|
|
|
import { Address, IAddress } from "@/types/address.model";
|
|
|
|
import { RoutingTransportationType, RoutingType } from "@/types/enums";
|
2022-10-05 12:13:19 +02:00
|
|
|
import { computed, defineAsyncComponent } from "vue";
|
2022-11-04 18:17:30 +01:00
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
|
import Car from "vue-material-design-icons/Car.vue";
|
|
|
|
import Bike from "vue-material-design-icons/Bike.vue";
|
|
|
|
import Bus from "vue-material-design-icons/Bus.vue";
|
|
|
|
import Walk from "vue-material-design-icons/Walk.vue";
|
|
|
|
import MapMarker from "vue-material-design-icons/MapMarker.vue";
|
|
|
|
import Close from "vue-material-design-icons/Close.vue";
|
|
|
|
|
|
|
|
const { t } = useI18n({ useScope: "global" });
|
2021-10-10 16:25:50 +02:00
|
|
|
|
|
|
|
const RoutingParamType = {
|
|
|
|
[RoutingType.OPENSTREETMAP]: {
|
|
|
|
[RoutingTransportationType.FOOT]: "engine=fossgis_osrm_foot",
|
|
|
|
[RoutingTransportationType.BIKE]: "engine=fossgis_osrm_bike",
|
|
|
|
[RoutingTransportationType.TRANSIT]: null,
|
|
|
|
[RoutingTransportationType.CAR]: "engine=fossgis_osrm_car",
|
|
|
|
},
|
|
|
|
[RoutingType.GOOGLE_MAPS]: {
|
|
|
|
[RoutingTransportationType.FOOT]: "dirflg=w",
|
|
|
|
[RoutingTransportationType.BIKE]: "dirflg=b",
|
|
|
|
[RoutingTransportationType.TRANSIT]: "dirflg=r",
|
|
|
|
[RoutingTransportationType.CAR]: "driving",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-10-05 12:13:19 +02:00
|
|
|
const MapLeaflet = defineAsyncComponent(
|
|
|
|
() => import("@/components/LeafletMap.vue")
|
|
|
|
);
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
address: IAddress;
|
|
|
|
routingType: RoutingType;
|
|
|
|
}>();
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-11-04 18:17:30 +01:00
|
|
|
const emit = defineEmits(["close"]);
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const physicalAddress = computed((): Address | null => {
|
|
|
|
if (!props.address) return null;
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
return new Address(props.address);
|
|
|
|
});
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const makeNavigationPath = (
|
|
|
|
transportationType: RoutingTransportationType
|
|
|
|
): string | undefined => {
|
|
|
|
const geometry = physicalAddress.value?.geom;
|
|
|
|
if (geometry) {
|
|
|
|
/**
|
|
|
|
* build urls to routing map
|
|
|
|
*/
|
|
|
|
if (!RoutingParamType[props.routingType][transportationType]) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const urlGeometry = geometry.split(";").reverse().join(",");
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
switch (props.routingType) {
|
|
|
|
case RoutingType.GOOGLE_MAPS:
|
|
|
|
return `https://maps.google.com/?saddr=Current+Location&daddr=${urlGeometry}&${
|
|
|
|
RoutingParamType[props.routingType][transportationType]
|
|
|
|
}`;
|
|
|
|
case RoutingType.OPENSTREETMAP:
|
|
|
|
default: {
|
|
|
|
const bboxX = geometry.split(";").reverse()[0];
|
|
|
|
const bboxY = geometry.split(";").reverse()[1];
|
|
|
|
return `https://www.openstreetmap.org/directions?from=&to=${urlGeometry}&${
|
|
|
|
RoutingParamType[props.routingType][transportationType]
|
|
|
|
}#map=14/${bboxX}/${bboxY}`;
|
2021-10-10 16:25:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-07-12 10:55:28 +02:00
|
|
|
};
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const addressLinkToRouteByCar = computed((): undefined | string => {
|
|
|
|
return makeNavigationPath(RoutingTransportationType.CAR);
|
|
|
|
});
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const addressLinkToRouteByBike = computed((): undefined | string => {
|
|
|
|
return makeNavigationPath(RoutingTransportationType.BIKE);
|
|
|
|
});
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const addressLinkToRouteByFeet = computed((): undefined | string => {
|
|
|
|
return makeNavigationPath(RoutingTransportationType.FOOT);
|
|
|
|
});
|
2021-10-10 16:25:50 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
const addressLinkToRouteByTransit = computed((): undefined | string => {
|
|
|
|
return makeNavigationPath(RoutingTransportationType.TRANSIT);
|
|
|
|
});
|
2021-10-10 16:25:50 +02:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
section.map {
|
2022-11-04 18:17:30 +01:00
|
|
|
height: 75vh;
|
|
|
|
width: 100%;
|
2021-10-10 16:25:50 +02:00
|
|
|
}
|
|
|
|
</style>
|