Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
MapBox retrieve location from geolocation of device browser

I need to show mapbox map, after the geolocalization of device I need to store the lat,lon values in variable js from this:

mapboxgl.accessToken='pk.xxxxxxxxxxx.xxxxxxxxxxxxx';
var coordinates = document.getElementById('coordinates');
var map = new mapboxgl.Map({
container: 'map',
center: [1.000, 1.000],
zoom: 1,
style: 'mapbox://styles/mapbox/streets-v11'
});

map.addControl(
new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl
})
);
map.addControl(new mapboxgl.NavigationControl());

map.addControl(
new mapboxgl.GeolocateControl({
positionOptions:{
enableHighAccuracy: true, timeout: 5000, maximumAge: 0 
}, // I need to retrieve lat/lon from here
fitBoundsOptions: {maxZoom:20},
showUserHeading: true,
showUserLocation: true,
trackUserLocation: true
})
);

var geojson = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
geometry: {
type: 'Point', coordinates: [94.00000,1.00000],},
properties: {title: 'Branch', description: 'nome'}
*}]*
};  

geojson.features.forEach(function(marker) {

var marker = new mapboxgl.Marker({draggable:true})
.setLngLat(marker.geometry.coordinates)
.addTo(map);

function onDragEnd() {
var lngLat = marker.getLngLat();
document.getElementById("longitude").value = lngLat.lng;
document.getElementById("latitude").value = lngLat.lat;
document.getElementById("upbranch").submit();
}

marker.on('dragend', onDragEnd);
}); 

This is code for map by MapBox I need to retrieve coordinates from map geolocation and use it in input field to store position in database

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda