mapboxgl.accessToken = 'pk.eyJ1IjoidmFsY3plODAiLCJhIjoiY2xpY2FhOTM5MGxwczNrdGV6a2J1Z2Q4diJ9.I_WRpX1aO4z32ajcE2Ef7A'; const geocoder = new MapboxGeocoder({ accessToken: mapboxgl.accessToken, types: 'country,region,place,postcode,locality,neighborhood,poi' }); 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", ""); });