Add GMaps link on points popups (#8)

Co-authored-by: Felipe Contreras Salinas <felipe@bstr.cl>
Reviewed-on: #8
This commit is contained in:
Felipe 2023-02-16 22:54:29 -03:00
parent 2b941a1624
commit d7c28bfa62
Signed by: Ludwig
GPG key ID: 441A26F83D31FAFF

View file

@ -1,5 +1,5 @@
import * as L from 'leaflet-contextmenu'; import * as L from 'leaflet-contextmenu';
import { Feature, FeatureCollection } from 'geojson'; import { Feature, FeatureCollection, Point } from 'geojson';
interface PlaceModel { interface PlaceModel {
id: number | null; id: number | null;
@ -282,6 +282,11 @@ async function setupMap(): Promise<void> {
popupStr += "<li><b>Horario:</b> " + feature.properties.open_hours + "</li>"; popupStr += "<li><b>Horario:</b> " + feature.properties.open_hours + "</li>";
if (feature.properties.description) if (feature.properties.description)
popupStr += "<li>" + feature.properties.description + "</li>"; popupStr += "<li>" + feature.properties.description + "</li>";
const lnglat = (feature.geometry as Point).coordinates;
popupStr += "<a href=\"https://www.google.com/maps/dir//" +
lnglat[1] + "," + lnglat[0] + "/@" + lnglat[1] + "," + lnglat[0] +
",15z\" target=\"_blank\">GMaps</a>"
popupStr += "</ul>"; popupStr += "</ul>";
layer.bindPopup(popupStr); layer.bindPopup(popupStr);