Javascript 谷歌地图飞行路线

Javascript 谷歌地图飞行路线,javascript,google-maps-api-3,Javascript,Google Maps Api 3,我正试图创建一张包含大量飞行路线的地图,这些路线是从数据库中收集的。 我使用的方法可能会有所改进: var flightPlanCoordinates1 = [ new google.maps.LatLng(53.63384159955519, 10.005816800985485), new google.maps.LatLng(40.689837457540044, -74.17809198377654) ]; var flightPath1 = new google.maps.Pol

我正试图创建一张包含大量飞行路线的地图,这些路线是从数据库中收集的。 我使用的方法可能会有所改进:

var flightPlanCoordinates1 = [ 
new google.maps.LatLng(53.63384159955519, 10.005816800985485), 
new google.maps.LatLng(40.689837457540044, -74.17809198377654) 
];
var flightPath1 = new google.maps.Polyline({ 
path: flightPlanCoordinates1, 
geodesic: true, 
strokeColor: '#FF0000',
strokeOpacity: 1.0, 
strokeWeight: 2 
});
flightPath1.setMap(map);
...
以上内容将反复循环,以显示从数据库收集的所有路由

所以我的问题是,是否有可能简化这一点,这样上面所有的都不必循环,只需要坐标

我的想法是,FlightPlanCoordinates 1的中断函数,用于中断每条路线,将是一个很好的解决方案


感谢您的帮助首先,定义您的多段线选项:

var pathOptions = { 
    geodesic: true, 
    strokeColor: '#FF0000',
    strokeOpacity: 1.0, 
    strokeWeight: 2 
};
var path = new google.maps.Polyline(pathOptions);
然后在循环中,可以使用以下选项创建多段线:

var pathOptions = { 
    geodesic: true, 
    strokeColor: '#FF0000',
    strokeOpacity: 1.0, 
    strokeWeight: 2 
};
var path = new google.maps.Polyline(pathOptions);
然后获得起点和终点,起点/终点/终点是您的坐标:

var start_point = new google.maps.LatLng(start_lat, start_lng);
var end_point = new google.maps.LatLng(end_lat, end_lng);
然后将其应用于多段线并在地图上设置:

path.getPath().setAt(0, start_point);
path.getPath().setAt(1, end_point);

path.setMap(map);

你明白了吗?

已经完成了;-点击飞机查看pathWell,它对我的项目没有帮助,除非flightradar是开源的。。。