【问题标题】:Google Map's DirectionsRenderer with OpenLayers带有 OpenLayers 的 Google 地图方向渲染器
【发布时间】:2011-02-03 11:23:59
【问题描述】:

我们的应用将 OpenLayers 与 Google 地图图层结合使用。我想知道是否可以在这个 OpenLayers 地图上使用 Google Maps 的 DirectionsRenderer api 来呈现路线?

此处的示例 - http://code.google.com/apis/maps/documentation/javascript/services.html#Directions - 在独立环境中运行良好。如果我们尝试将其与 OpenLayers 集成,则不会渲染方向。

有什么帮助吗?

谢谢, 斯里达尔

【问题讨论】:

    标签: google-maps google-maps-api-3 openlayers map-directions


    【解决方案1】:

    OpenLayers 不包含 Google 地图的方向功能。您仍然可以在 OpenLayers 中使用 Google Maps 图层,并使用 Google 的 API 向 Directions Services 发出请求。

    如果您在他们的文档页面上提出请求,例如:

    directionsService.route(request, function(result, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(result);
    }
    

    });

    您会注意到 result.routes.overview_path 包含路线的所有点。然后您可以使用 OpenLayers.Layers.Vector 在 Google Maps 图层上方的单独图层中渲染此路线。

    【讨论】:

      猜你喜欢
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      相关资源
      最近更新 更多