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

308
Views
Complemento de clúster de Leaflet: cómo agrupar marcadores solo cuando tienen la misma propiedad

Yo suelo:

  • Folleto 1.3.4
  • el complemento del clúster: https://github.com/Leaflet/Leaflet.markercluster

¿Cómo hago para que los marcadores de mi capa geojson se agrupen solo si tienen el mismo valor en una propiedad? Los marcadores están localizados en cada estado de los Estados Unidos y quiero que los marcadores se agrupen solo entre marcadores del mismo estado. En la capa geojson, una propiedad indica a qué estado pertenece el marcador (feature.properties.state)

Gracias !

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente haga un MarkerClusterGroup por estado:

 // [state]: mcg const mcgDictionary = {}; L.geoJSON(myGeoJSONdata, { onEachFeature(feature, layer) { const state = feature.properties.state; // Initialize a new MCG for the State, if it does not exist yet mcgDictionary[state] ??= L.markerClusterGroup(); mcgDictionary[state].addLayer(layer); } }); // Do not forget to add all MCG's to the map Object.values(mcgDictionary).forEach((mcg) => mcg.addTo(map));

Nota: a un nivel de zoom bajo, es probable que todos estos MCG se superpongan.

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!