我创建了一个方法,它使用c#从数据库返回纬度和经度数组,现在我想将此列表传递给JavaScript以在谷歌地图上绑定poly_line路径。
答案 0 :(得分:2)
var polyOptions = {
strokeColor: '#000000',
strokeOpacity: 1.0,
strokeWeight: 3
}
poly = new google.maps.Polyline(polyOptions);
poly.setMap(map);
var path = new MVCArray;
$.getJSON('json.cs', function(data) {
//var items = [];
$.each(data, function(key, val) {
path.push(new google.maps.LatLng(val.lat, val.longi));
});
// now update your polyline to use this path
poly.setPath(path);
});
<body onload="initialize()">
<div id="map_canvas" style="width:90%; height:100%"></div>
</body>
</html>