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

114
Views
¿Cómo puedo hacer que Leaflet markerClusters funcione con la lectura de datos de CSV con PapaParse?

Estoy tratando de combinar direcciones de dos tutoriales de folletos:

  1. Obtener datos de marcador de CSV usando PapaParse: https://github.com/HandsOnDataViz/leaflet-map-csv
  2. Tutorial de agrupación: https://asmaloney.com/2015/06/code/clustering-markers-on-leaflet-maps/

y esto es lo que tengo:

 //create cluster group var markerClusters = L.markerClusterGroup(); // Read markers data from data.csv $.get('./data_jittered.csv', function(csvString) { // Use PapaParse to convert string to array of objects var data = Papa.parse(csvString, {header: true, dynamicTyping: true}).data; // For each row in data, create a marker and add it to the map // For each row, columns `Latitude`, `Longitude`, and `Title` are required for (var i in data) { var row = data[i]; var marker = L.marker([row.New_Lat, row.New_Long], { opacity: 1 }).bindPopup(row.Title); marker.addTo(map); markerClusters.addLayer(marker); } map.addLayer(markerClusters);

Actualmente, los marcadores se están cargando pero la función de agrupación no funciona: https://maggiehm.github.io/nzamorawilson-map/

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

0

marker.addTo(map);

era el problema. Seguí el ejemplo proporcionado por Dom en los comentarios aquí: stackoverflow.com/a/66616249/10684798

y actualicé el código (con variables simplificadas) a:

 var markers = L.markerClusterGroup(); $.get('./data_jittered.csv', function(csvString) { var data = Papa.parse(csvString, {header: true, dynamicTyping: true}).data; for (var i in data) { var row = data[i]; var marker = L.marker([row.New_Lat, row.New_Long], { opacity: 1 }).bindPopup(row.Title); markers.addLayer(marker); } }); map.addLayer(markers)

La función de agrupación funciona ahora: https://maggiehm.github.io/nzamorawilson-map/

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!