<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Get Lat/Long for Google Autocomplete or Route results?]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1889</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1889&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Get Lat/Long for Google Autocomplete or Route results?.]]></description>
		<lastBuildDate>Tue, 07 Dec 2021 09:06:33 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Get Lat/Long for Google Autocomplete or Route results?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7954#p7954</link>
			<description><![CDATA[<p>Hello.</p><p>1. Google Autocomplete API does not return prediction locations.<br />To get full location information, you need to make a request to Google Places Details API.<br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMapsGooglePlaceDetails.html#a372fc11e600f9e17d1a441b9795d0c1d">https://infinity-code.com/doxygen/onlin … b9795d0c1d</a></p><p>2. <br /></p><div class="codebox"><pre><code>OnlineMapsVector2d endLocation = result.routes[0].legs.Last().end_location;</code></pre></div><p>or<br /></p><div class="codebox"><pre><code>OnlineMapsVector2d endLocation = result.routes[0].overview_polylineD.Last();</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 07 Dec 2021 09:06:33 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7954#p7954</guid>
		</item>
		<item>
			<title><![CDATA[Get Lat/Long for Google Autocomplete or Route results?]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7953#p7953</link>
			<description><![CDATA[<p><strong><span class="bbu">1) Lat/Long from Google Autocomplete:</span></strong></p><p>If I run a Google autocomplete query, it will return results in the format of OnlineMapsGooglePlacesAutocompleteResult, which gives me:</p><p>- string description - human readable address<br />- string reference - a reliable string identifier for the address<br />- string id - deprecated<br />- string place_id - an identifier that can be passed into Places API to get info about location</p><p>If I want to get the long/latitude for each location, I presume the most efficient way would be to use the place_id somehow. Is there any built in way or simple code I can use that will turn a place_ID into a lat/long so I can set a marker on map to it? Are there any built in methods?</p><p>I know we have geocoding by name here: <a href="https://infinity-code.com/atlas/online-maps/pages/FindLocationExample.html">https://infinity-code.com/atlas/online- … ample.html</a></p><p>One could use &quot;description&quot; into this geocoding method but in principle this will not be as correct as using place_id or reference from what I understand. Perhaps this doesn&#039;t matter and passing in the description is good enough.</p><p><strong><span class="bbu">2) Long/Lat from Directions Request:</span></strong><br />Second if I have a route request from a Directions request which returns as follows:</p><div class="codebox"><pre><code> private void OnGoogleDirectionsComplete(string response) { //for drawing routes
        Debug.Log(response);

        // Try load result
        OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);
        if (result == null || result.routes.Length == 0) return;

        // Get the first route
        OnlineMapsGoogleDirectionsResult.Route route = result.routes[0];

        // Draw route on the map
        OnlineMapsDrawingElementManager.RemoveAllItems();
        OnlineMapsDrawingElementManager.AddItem(new OnlineMapsDrawingLine(route.overview_polyline, Color.red, 2));</code></pre></div><p>Is it possible to easily get from &quot;route&quot; the destination long/lat? Ie. if &quot;route&quot; contains a list of long/lat values to compose the route, how do I get the last entry to the route long/lat (which will be the destination)?</p><p>I can see in the Debug output it provides as part of &quot;response&quot;:<br />&nbsp; &nbsp;&lt;end_location&gt;<br />&nbsp; &nbsp; &nbsp;&lt;lat&gt;______&lt;/lat&gt;<br />&nbsp; &nbsp; &nbsp;&lt;lng&gt;______&lt;/lng&gt;<br />&nbsp; &nbsp; &lt;/end_location&gt;</p><p>How do I access this end location lat/long from the code above?</p><p>Thanks as always. I almost have all my functions working thanks to your help so I won&#039;t hopefully be bugging you too much longer. <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[null@example.com (mikejm)]]></author>
			<pubDate>Tue, 07 Dec 2021 08:08:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7953#p7953</guid>
		</item>
	</channel>
</rss>
