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

237
Views
setLngLat en el marcador no funciona - mapbox

Quiero cambiar el marcador actual a una nueva posición.

 let marker = new mapboxgl.Marker({ color: 'red', draggable: true }) useEffect(() => { initMap() }, []) const initMap = () => { mapboxgl.accessToken = '*******1g'; if (mapboxgl.getRTLTextPluginStatus() !== 'loaded') { mapboxgl.setRTLTextPlugin( 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js', null, true // Lazy load the plugin ); } const map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/streets-v11', center: [51.446558, 33.980739], zoom: 12, textAlign: 'left' }); map.on('click', function (e) { var coordinates = e.lngLat; marker.setLngLat(coordinates).addTo(map); //this line does't setted. }); setTimeout(() => { initMapMarker(map, 51.41691337396722, 34.022980413997786) }, 1000); } const initMapMarker = (map, initLon, initLat) => { // eslint-disable-next-line no-unused-vars marker.setLngLat([initLon, initLat]) .addTo(map); marker.on('dragend', () => { const lngLat = marker.getLngLat(); getFormatedAddress(lngLat) }); }

pero después de hacer clic en el mapa, esta línea no funcionó:

 marker.setLngLat(coordinates).addTo(map);

Eliminó el marcador predeterminado.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

resuelto, importa esta línea:

 import 'mapbox-gl/dist/mapbox-gl.css';
about 4 years ago · Juan Pablo Isaza Report
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!