开发者

Google Map's DirectionsRenderer with OpenLayers

开发者 https://www.devze.com 2023-02-08 02:32 出处:网络
Our app uses OpenLayers with the Google Map layer.I want to know if it is possible to render directions using the DirectionsRenderer api of Google Maps on this OpenLayers map?

Our app uses OpenLayers with the Google Map layer. I want to know if it is possible to render directions using the DirectionsRenderer api of Google Maps on this OpenLayers map?

The example here - http://code.google.com/apis/maps/documentation/javascript/services.html#Dir开发者_如何学运维ections - works fine in a stand-alone environment. If we try to integrate it with OpenLayers, the directions don't get rendered.

Any help?

Thanks, Sridhar


OpenLayers doesn't wrap Directions functionality of Google Maps. You can though still use Google Maps layer in OpenLayers and make requests to Directions Services using Google's API.

If you make request like in example on their documentation page:

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

});

you will notice that result.routes.overview_path contains all points for the route. Then you can use OpenLayers.Layers.Vector to render this route in a separate layer above Google Maps layer.

0

精彩评论

暂无评论...
验证码 换一张
取 消