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

229
Visualizações
Custom Leaflet markers when markers are coded as a layer, not built individually?

Leaflet map adapted from this tutorial builds markers like:

async function render_markers() {
const markers = await load_markers();
L.geoJSON(markers)
    .bindPopup((layer) => layer.feature.properties.name)
    .addTo(layerGroup);
}

I want to change this map's markers to any of the solutions recommended in this good thread. But I don't know how to get a handle on them as all markers seem built individually, eg:

L.marker([51.5, -0.09], {icon: greenIcon}).addTo(map);

Leaflet documentation also only seems to show how to change markers individually. How can we get a solution like this working with the way our map is built? What are we missing?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are searching for this Leaflet-Tutorial.

To customize markers or circles you need to add pointToLayer function:

L.geoJSON(markers, {
    pointToLayer: function (feature, latlng) {
        return L.marker(latlng, {icon: greenIcon} );
    }
})
    .bindPopup((layer) => layer.feature.properties.name)
    .addTo(layerGroup);
about 4 years ago · Juan Pablo Isaza Relatório
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