我是谷歌地图的新手,在互联网论坛搜索和研究后,我无法完成这项工作。根据谷歌地图的原始代码,我不想绘制一条折线图,其中包含两条不同颜色的不同飞行路径。
原始代码我想改变:
function initialize() {
var myLatLng = new google.maps.LatLng(0, -180);
var mapOptions = {
zoom: 3,
center: myLatLng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
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)
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
感谢您的帮助。
答案 0 :(得分:0)
您需要另一个google.maps.Polyline()
...
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)
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
var flightPlanCoordinates2 = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(-27.46758, 153.027892)
];
var flightPath2 = new google.maps.Polyline({
path: flightPlanCoordinates2,
strokeColor: '#FF00FF',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
flightPath2.setMap(map);
...