Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
MapBox recupera la ubicación de la geolocalización del navegador del dispositivo

Necesito mostrar el mapa de mapbox, después de la geolocalización del dispositivo, necesito almacenar los valores de latitud y longitud en la variable js de esto:

 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); });

Este es el código para el mapa de MapBox. Necesito recuperar las coordenadas de la geolocalización del mapa y usarlo en el campo de entrada para almacenar la posición en la base de datos.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!