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

145
Visualizações
How to update map features properties

I have already mapped my map as below. After mapping, I added some properties to my map features. So How could I update this map. I try this map.getSource('lines').setData(responseData) but I got two overlapping map. Any help is appreciated.

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'])
})

Adding some properties to the already mapped map.

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

Updating the map after adding properties

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

But instead of updating the map, I got two overlapping maps. How can I fixed it please?

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