【问题标题】:google maps flight path谷歌地图飞行路线
【发布时间】:2013-12-29 11:44:29
【问题描述】:

我正在尝试创建包含从数据库收集的大量飞行路径的地图。 我使用的方法可能会改进一点:

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);
...

上面会循环显示所有从数据库中收集的路由。

所以我的问题是,如果可以简化这一点,那么以上所有内容都不必循环,只有坐标。

我的想法是“flightPlanCoordinates1”的“中断”功能,为每条路线中断,将是一个很好的解决方案。

感谢任何帮助

【问题讨论】:

  • 已经搞定了 ;-) flightradar24.com(点击平面看路径)
  • 嗯,这对我的项目没有帮助,除非 flightradar 是开源的......

标签: javascript google-maps-api-3


【解决方案1】:

首先,定义你的折线选项:

var pathOptions = { 
    geodesic: true, 
    strokeColor: '#FF0000',
    strokeOpacity: 1.0, 
    strokeWeight: 2 
};

然后在您的循环中,您可以使用以下选项创建折线:

var path = new google.maps.Polyline(pathOptions);

然后获取起点和终点(其中 start_lat/lng end_lat/lng 是你的坐标):

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);

你明白了吗?

【讨论】:

    猜你喜欢
    • 2012-05-17
    • 1970-01-01
    • 2016-08-28
    • 2015-04-18
    • 1970-01-01
    • 2014-08-12
    • 2014-08-14
    • 2012-12-08
    • 2011-07-22
    相关资源
    最近更新 更多