[英]google maps draw a line between two points
I am getting the latitude/longitude from the DB. 我正在从数据库获取纬度/经度。 I am unable to draw a line between two distances.
我无法在两个距离之间画一条线。 Here is my code
这是我的代码
var auto_refresh = setInterval(
function () {
$.get('http://developer.allsecure.me/Location/longlat', function (data) {
map_canvas.setCenter(new google.maps.LatLng(data.startlat, data.startlong));
clearMarkers();
setMarker(map_canvas, 'center', new google.maps.LatLng(data.startlat, data.startlong), '', '/img/device.png', '', '', true);
var line = new google.maps.Polyline({
path: [new google.maps.LatLng(data.startlat, data.startlong), new google.maps.LatLng(data.endlat, data.endlong)],
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 10,
map: map
});
}, 'json');
}, 1000);
I don't know why it isn't adding the polylines between the two distances. 我不知道为什么不在两个距离之间添加折线。
As the comment above was the actual solution 正如上面的评论是实际的解决方案
When you define the line you use map: map
shouldn't this be map: map_canvas
? 定义线时,请使用
map: map
不应将其设为map: map_canvas
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.