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

时间:2011-07-23 11:31:37

标签: google-maps

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

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

由于 NIK

1 个答案:

答案 0 :(得分: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);
}

Google网页上有很多例子。

相关问题