在谷歌地图中显示航班路径

Nik*_*Nik 4 google-maps

嗨,我想在Google地图中显示航班路径.我有地理坐标,并希望在此图像上创建这样的内容:http://main.makeuseoflimited.netdna-cdn.com/wp-content/uploads/2011/02/flightarrivals.png?54167

有没有人举个好榜样?这可能吗?

谢谢Nik

Jam*_*unt 5

API文档怎么样?

http://code.google.com/apis/maps/documentation/javascript/overlays.html

您可以添加标记,线条,文本等.所有API中都有描述.

从文档中无耻地抓取如何在地图上绘制折线的示例:

function initialize() {
  var myLatLng = new google.maps.LatLng(0, -180);
  var myOptions = {
    zoom: 3,
    center: myLatLng,
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  var map = new google.maps.Map(document.getElementById("map_canvas"),
      myOptions);
  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);
}
Run Code Online (Sandbox Code Playgroud)

Google网页上有更多示例.

  • 好吧 - 只需泡沫,冲洗,重复.没有人会发布您需要的确切代码,因此您需要使用API​​并将其应用于您的特定问题.如果您在实施过程中遇到困难,请回过头来发布特定问题,友好的SO人员将非常乐意为您提供帮助. (2认同)