backoffice/web/js/geosearch.js

20 lines
636 B
JavaScript
Raw Normal View History

2023-11-11 19:16:05 +01:00
mapboxgl.accessToken = 'pk.eyJ1IjoidmFsY3plODAiLCJhIjoiY2xpY2FhOTM5MGxwczNrdGV6a2J1Z2Q4diJ9.I_WRpX1aO4z32ajcE2Ef7A';
const geocoder = new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
2023-11-12 18:41:15 +01:00
types: 'country,region,place,postcode,locality,neighborhood,poi'
2023-11-11 19:16:05 +01:00
});
2023-11-20 23:16:56 +01:00
geocoder.addTo('#placeUpdateInput');
place = document.getElementById("placeUpdateInput");
geocoder.on("result", (e) => {
place.setAttribute("data-latitude", e.result.center[1]);
place.setAttribute("data-longitude", e.result.center[0]);
});
geocoder.on("clear", () => {
place.setAttribute("data-latitude", "");
place.setAttribute("data-longitude", "");
});