0

Is there a simple way to achieve showing the output from DirectionServices onto a Google Map? The closest I could find was this answer -- How to draw road directions between two geocodes in android google map v2?

But that needs a bit of modification...

I'm ok with either Google API or 3rd party libraries too

Thanks,

Ram

Community
  • 1
  • 1
zooter
  • 2,128
  • 1
  • 13
  • 23

1 Answers1

0

Given in Google Maps JavaScript API - Displaying the DirectionsResult, you may opt to handle yourself the DirectionsResult which contains the result of the directions of the query or you can choose to automatically handle displaying the result on a map by passing a DirectionsRenderer object.

To display a DirectionsResult using a DirectionsRenderer, you simply need to do the following:

  • Create a DirectionsRenderer object.

  • Call setMap() on the renderer to bind it to the passed map.

  • Call setDirections() on the renderer, passing it the DirectionsResult. Because the renderer is an MVCObject, it will automatically detect any changes to its properties and update the map when its associated directions have changed.

A DirectionsRenderer not only handles display of the polyline and any associated markers, but also can handle the textual display of directions as a series of steps. To do so, simply call setPanel() on your DirectionsRenderer, passing it the <div> in which to display this information.

More information and examples to fully understand Google Maps JavaScript API - Directions Service can be obtained from the documentation.

Community
  • 1
  • 1
Teyam
  • 7,686
  • 3
  • 15
  • 22
  • are you sure this will work on Android? The documentation and functions you've presented are Javascript – zooter Apr 18 '16 at 10:27
  • For Android related, please check [Google Maps Intents](https://developers.google.com/maps/documentation/android-api/intents#top_of_page). – Teyam Apr 21 '16 at 06:01