Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
Leaflet marker in polygon

I made a map with Leaflet.js with GeoJSON data and all it's right. But when i want put a marker in a Polygon i cant.

I leave a clipping of my code. Everything works except the marker

          data: squareParkData,
          color: "black",
          fillColor: "green",
          fillOpacity: 0.3,
          weight: 1,
          onEachFeature:onEachFeature,
          pointToLayer: function (feature, latlng) {
            return L.marker(latlng, { icon: municipalDependenceIcon });
          }
        }) ```

Thanks
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

According to the specifications, it seems like the pointToLayer is used for geomtery type 'points'.

Points are handled differently than polylines and polygons

You can use the (onEachFeature's) feature geometries and add a new marker to the layer.

To compute for the center of multiple points, you can use TurfJS https://turfjs.org/docs/#centroid

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda