简体   繁体   中英

Unable to add points to Leaflet.js heatmap

I am using Leaflet.js and Leaflet.heat. When I add points I get "unable to get property lat of undefined or null reference". When I print the value of point in console and paste it in the code, it works. What am I doing wrong?

 setTimeout(function () { if (i >= num_frames) { return; } try { var points = "[" + array_all_snapshot[i] + "]"; console.log(points); var points = array_all_snapshot[i]; var heat = L.heatLayer(points, { maxZoom: 10 }) .addTo(map); } catch (e) { console.log(array_all_snapshot[i]); console.log(e.toString()); } i += 1; requestAnimationFrame(function () { repeatOften(i); }); }, 11 ); 

Found my mistake. I had to JSON.parse() the points.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM