Petr
Petr

Reputation: 1219

Google maps - Get address

Google Maps Api: I have the objects like (sure just part of code...):

var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
var result = directionsDisplay.getDirections();

I need to know the start and destination address(string format) of the route.

For instance I can get LatLng like:

result.routes[0].overview_path[0]

Upvotes: 0

Views: 490

Answers (1)

duncan
duncan

Reputation: 31912

For that you probably want to use the DirectionsLeg.start_address and DirectionsLeg.end_address values.

See https://developers.google.com/maps/documentation/javascript/directions#Legs

So result.routes[0].legs[0].start_address for the starting address of the first leg of the directions route.

And result.routes[0].legs[result.routes[0].legs.length-1].end_address for the ending address of the last leg of the directions route.

Upvotes: 1

Related Questions