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

85
Views
Actualice las coordenadas de FeatureCollection Geojson en el mapa del cuadro de mapa cada 2 segundos

Soy nuevo en Javascript y mapbox y quiero ayuda para resolver un problema (código a continuación). Estoy usando algunas coordenadas ({{coords}}) provenientes de un script de python y las estoy agregando como geojson al mapa (featureCollection). Quiero que estas coordenadas geojson se actualicen cada 2 segundos. He usado setData(), pero mis coordenadas no se actualizan en el mapa. ¿Puedes ayudar y dar algunos consejos? Muchísimas gracias.

 var longLat = {{coords}}; var featureCollection = []; for(var itemIndex in longLat) { featureCollection.push({ "type": "Feature", "geometry": { "type": "Point", "coordinates": longLat[itemIndex] }, "properties": { "title": "boat", "icon": "ferry" } }); } map.on('load', function () { map.addSource('ship', { type: 'geojson', data: featureCollection }); map.addLayer({ "id": "points", "type": "symbol", "source": { "type": "geojson", "data": { "type": "FeatureCollection", "features": featureCollection } }, "layout": { "icon-image": "{icon}-15", "text-field": "{title}", "text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"], "text-offset": [0, 0.6], "text-anchor": "top" } }); window.setInterval(function() { map.getSource('ship').setData(featureCollection); }, 2000); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No usó la fuente de 'envío' para la capa, por lo que actualizar los datos de origen ( map.getSource('ship').setData ) no activaría la reproducción.

Cambie la propiedad de origen de map.addLayer(...) , Pruebe map.addLayer({...,source:'ship'})

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!