[英]L.multiPolyline does not show anything on map (leaflet)
This is my code to add a polyline to a map. 这是我的代码,用于向地图添加折线。 The map works fine and I've used GeoJSON objects to display routes on the map.
该地图运行良好,并且我已使用GeoJSON对象在地图上显示路线。
var polyLine = L.multiPolyline(window.routeArray,{color: 'blue'});
polyLine.addTo(map);
window.routeArray is an array of latLngs This is the output if I do an console.log(" " + window.array);
window.routeArray是latLngs的数组。如果我执行
console.log(" " + window.array);
(I'm using node.js with this.) (我正在与此一起使用node.js。)
LatLng(49.24905, -123.11531),LatLng(49.24854, -123.07618),LatLng(49.24022, -123.07642),LatLng(49.24034, -123.09034),LatLng(49.23287, -123.09054),LatLng(49.23319, -123.10146),LatLng(49.24045, -123.10138)
The map doesn't show anything and I can't figure out why. 该地图没有显示任何内容,我也不知道为什么。
Any help would be appreciated. 任何帮助,将不胜感激。
Two suggestions, 1) what you've described is a polyline, not a multipolyline. 有两个建议,1)您所描述的是多段线,而不是多段线。 2) the points must be added as a javascript array as an array of arrays, for example
2)点必须作为一个javascript数组添加为一个数组数组,例如
var line_points = [
[38.893596444352134, -77.0381498336792],
[38.89337933372204, -77.03792452812195],
[38.89316222242831, -77.03761339187622],
[38.89302861514842, -77.03731298446655],
[38.892920059048464, -77.03691601753235]
];
var line = L.polyline(line_points).addTo(map);
This example may help 这个例子可能有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.