在 angularjs 中的 google 地图上画线
Draw line on google map in angularjs
我想在加载地图时,在两个城市之间绘制一条直线,例如山核桃和伦敦。
我如何在 Google 地图上用 angularjs?
在两个城市之间画一条直线
绘图Simple Polylines
,你可以像这样在arrays
中保存latitude
和longitude
:
var flightPlanCoordinates = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
];
然后,用google.maps.Polyline
画出来。
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
详情请参考here。
我想在加载地图时,在两个城市之间绘制一条直线,例如山核桃和伦敦。 我如何在 Google 地图上用 angularjs?
在两个城市之间画一条直线绘图Simple Polylines
,你可以像这样在arrays
中保存latitude
和longitude
:
var flightPlanCoordinates = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
];
然后,用google.maps.Polyline
画出来。
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
详情请参考here。