Google Map's DirectionsRenderer with OpenLayers

4.8k views Asked by At

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#Directions - 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

1

There are 1 answers

0
igorti On BEST ANSWER

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.