Estoy usando un mapa de folletos con mis datos en un archivo csv para marcadores. los marcadores no aparecen en el mapa. no puedo solucionar el problema.
mapa.js
''' let path = "data/ppv_full.csv"; // create the map function createMap(){ map = L.map('map').setView([0,0],3); // function to read csv data function readCSV(){ Papa.parse(path, { header: true, download: true, complete: function(data) { console.log(data); // map the data mapCSV(data); } }); } function mapCSV(data){ // loop through each entry data.data.forEach(function(item,index){ // create marker let marker = L.marker([item.latitude,item.longitude]) // add marker to featuregroup markers.addLayer(marker) }) // add featuregroup to map markers.addTo(map) // fit markers to map map.fitBounds(markers.getBounds()) } '''este es el error que estoy recibiendo en la consola:
LatLng.js:32 Uncaught Error: Invalid LatLng object: (undefined, undefined) at new D (LatLng.js:32:9) at j (LatLng.js:123:11) at i.initialize (Marker.js:102:18) at new i (Class.js:22:20) at t.marker (Marker.js:385:9) at map.js:42:18 at Array.forEach (<anonymous>) at mapCSV (map.js:40:12) at Object.complete (map.js:31:4) at l.parseChunk (papaparse.min.js:7:6757)la página HTML solo muestra el mapa sin ningún marcador.
Esto significa que hay al menos un item en sus entradas, que:
latitude y longitudelatitude y longitude configuradas como undefined . Debe usar un depurador para ingresar al bucle forEach e inspeccionar el valor del item . (o use console.log , pero eso no es una depuración adecuada)