在Google Maps API V3中使用LatLng坐标数组绘制折线
Drawing PolyLine Using an Array of LatLng Coordinates in Google Maps API V3
我试图在Javascript中使用谷歌地图API v3绘制动态折线,这是我使用的代码片段:
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myTrip=new Array();
//var y=new google.maps.LatLng(28.360012,77.031527);
//var z=new google.maps.LatLng(28.360124,77.031429);
myTrip.push(new google.maps.LatLng(28.360012,77.031527));
myTrip.push(new google.maps.LatLng(28.360124,77.031429));
myTrip.push(new google.maps.LatLng(28.361024,77.034129));
var flightPath=new google.maps.Polyline({
path:myTrip,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2
});
flightPath.setMap(map);
google.maps.event.addDomListener(window, 'load', initialize);
这不是在地图上绘制折线。
有人能帮我一下吗?
您缺少一个initialize
功能:
function initialize() {
var mapProp = {
center: new google.maps.LatLng(28.360012, 77.031527),
zoom: 18,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var myTrip=new Array();
myTrip.push(new google.maps.LatLng(28.360012,77.031527));
myTrip.push(new google.maps.LatLng(28.360124,77.031429));
myTrip.push(new google.maps.LatLng(28.361024,77.034129));
var flightPath=new google.maps.Polyline({
path:myTrip,
strokeColor:"#0000FF",
strokeOpacity:0.8,
strokeWeight:2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
相关文章:
- EaseJS拖放;放下(动画CC)电影剪辑的鼠标坐标
- 如何在d3.js中返回路径的y坐标
- 在谷歌地图上获取事件的x,y坐标
- 通过ajax将坐标传递到php服务器端,并在处理后检索到javascript
- 当带有渲染器的DOM元素不在屏幕顶部时,移动了场景的坐标
- 应用“;矢量“;指向传单中的Point或LatLng
- 如何在JS Leatflet绘图插件中获取圆的坐标
- 点击(右键点击)使用传单地图库获取图像覆盖的像素坐标
- 查找带有边框的HTML5 Canvas(点击)事件的坐标
- HTML5获取弧的坐标's结束
- 将谷歌地图 api latLng 坐标存储到 js 数组
- 获取基于百分比或基于像素的x&y坐标来自latlng
- 如何知道给定的latlng是否在geojson多边形坐标内
- 如何从(x, y)屏幕坐标转换为LatLng(谷歌地图)
- Jquery/JavaScript公式,添加x米/英里/公里到latlng坐标
- 在Google Maps API V3中使用LatLng坐标数组绘制折线
- 在谷歌地图上绘制来自Json数组的LatLng坐标-所有标记都堆叠在同一位置
- 我如何将一个点从[x,y]坐标投影到传单中的LatLng
- 转换DATUM WGS84坐标为谷歌地图v3 JS Latlng对象
- 查找 LatLng 坐标是否位于另外两个 LatLng 坐标之间