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

138
Views
Cómo actualizar las propiedades de las características del mapa

Ya he mapeado mi mapa como se muestra a continuación. Después del mapeo, agregué algunas propiedades a las características de mi mapa. Entonces, ¿cómo podría actualizar este mapa? Probé este map.getSource('lines').setData(responseData) pero obtuve dos mapas superpuestos. Cualquier ayuda es apreciada.

 map.on('load', function() { map.addSource('lines', { type: 'geojson', data: responseData }); map.addLayer({ 'id': 'lines', 'type': 'fill', 'source': 'lines', 'layout': {}, 'paint': { 'fill-color': '#4682B4', 'fill-opacity': 0.8, } }); map.setPaintProperty('lines', 'fill-color', ['get', 'color']) })

Agregando algunas propiedades al mapa ya mapeado.

 const links = await fetch(`http://127.0.0.1:8000/api/network/4/edges/`); const linksData = await links.json(); let ar = map.getSource('lines')._data.features.map((item, i) => { let currentLayer = linksData.find( element => element.edge_id === item.properties.edge_id) item.properties.name = currentLayer.name item.properties.length = currentLayer.length item.properties.speed = currentLayer.speed item.properties.lanes = currentLayer.lanes })

Actualizar el mapa después de agregar propiedades

 map.getSource('lines').setData(responseData) map.setPaintProperty('lines', 'fill-color', ['interpolate', ['linear'], ['get', 'lanes'], 0, 'rgb(255, 255, 255)', 5, 'rgb(255, 0, 0)'])

Pero en lugar de actualizar el mapa, obtuve dos mapas superpuestos. ¿Cómo puedo arreglarlo por favor?

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!