Question

I am trying to show directions between 2 'establishment' search results from the Places API, but what is the best way to pass these locations into directions?

When I use the Places library and get the search results, it seems like the best way to pass the location to directions is to use the place[0].geometry.location, which gives a longitude and latitude of the result.

However, with just the longitude and latitude of the place, directions geocodes this into an address and returns results with approximate addresses, whereas I would like it to show the establishment name from Places instead.

For example, after Places return the result for SF MOMA, I would like directions to show directions from somewhere like "San Francisco Museum of Modern Art" instead of "150 3rd Street, San Francisco, CA 94103, USA", which is indescriptive of the location.

Using place[0].name as the location for directions is inaccurate too.

Thanks!! Cody

Was it helpful?

Solution

place[0].name worked for me, but you can also append the address to the name:

[place[0].name, place[0].vicinity].join(' ');

Example Directions query

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top