<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=461&amp;type=atom" />
	<updated>2017-03-17T20:35:15Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=461</id>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2044#p2044" />
			<content type="html"><![CDATA[<p>The link to overpass-turbo is already in the documentation.<br />This is a very useful and convenient web service.</p><p>Only you know which web service is best for your application.<br />If you think you need OSM Overpass, just use it.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-17T20:35:15Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2044#p2044</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2042#p2042" />
			<content type="html"><![CDATA[<p>Their Export tab works not only with the data but with the query. Exporting the above query to text gets me this, which seems to be working for me to get everything, it&#039;s a matter of parsing through the data at that point.</p><div class="codebox"><pre><code>string requestData = &quot;(node(34.16870691998642, -118.50798726081847, 34.17677564022297, -118.49230170249939);&lt;;);out meta;&quot;;</code></pre></div><p>If you see any reason I shouldn&#039;t be continuing this line of inquiry, do let me know. Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-17T18:51:20Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2042#p2042</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2041#p2041" />
			<content type="html"><![CDATA[<p>I found an *incredibly* useful web site to help me experiment with OSM queries- not sure if you reference in the documentation, but if not, you might want to add it:</p><p><a href="http://overpass-turbo.eu/">http://overpass-turbo.eu/</a></p><p>This might give me what I need to get what I want. Here&#039;s the code they give to get all data in a bounding box:</p><div class="codebox"><pre><code>/*
This is a simple map call.
It returns all data in the bounding box.
*/
[out:xml];
(
  node({{bbox}});
  &lt;;
);
out meta;</code></pre></div><p>But I&#039;m not sure how to specify the bounding box using your API. Let me know if I&#039;m barking up the right tree and if you can help me specify the bounding box using the syntax they describe and the corners of the Tileset map.</p><p>Thanks again!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-17T18:12:28Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2041#p2041</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2039#p2039" />
			<content type="html"><![CDATA[<p>Thanks for that example, it&#039;s especially useful to use as a guide for when I want to use a resource for which there are no classes native to Online Maps.</p><p>It doesn&#039;t seem to give me what I can get from OSM, though. To give you an example, the area I&#039;m testing in has some features that work perfectly when I do a Query Feature via OSM, but return misleading results when using the Foursquare code above.</p><p>An example. Set the Tileset control to:</p><div class="codebox"><pre><code>latitude 34.1820437820025
longitude -118.478416533137
zoom 17
provider OSM
type Mapnik</code></pre></div><p>Clicking in the red national guard station near the top of the map using the Foursquare Code gives me </p><div class="codebox"><pre><code>Carlo Inc
Office </code></pre></div><p>and when I query feature in OSM I get </p><div class="codebox"><pre><code>Nearby features
No features found
Enclosing features
Military Area Sepulveda Air National Guard Station
{etc}</code></pre></div><p>If I click in the middle of the big Water Reclamation Plant in the center of the map, using the Foursquare code, I get</p><div class="codebox"><pre><code>Woodley Avenue Park
Park</code></pre></div><p>but when I query feature on OSM I get:</p><div class="codebox"><pre><code>Nearby features
Service Road #94233762
Industrial #306664814
Enclosing features
Industrial Area Tillman Water Reclamation Plant
{etc}</code></pre></div><p>I think what&#039;s going on is that there aren&#039;t as many map features defined (who&#039;d want to &quot;check in&quot; to a water treatment plant?), and it&#039;s returning the nearest one, without quite so much detail, as Foursquare doesn&#039;t have the boundaries of each feature defined the way OSM does. That means if the point is closer to the center of one feature, Foursquare can&#039;t tell you&#039;re within the boundaries of another feature.</p><p>Is there a way for me to get the results yielded doing a Feature Query on OSM?</p><p>Looking here:<br /><a href="https://blog.openstreetmap.org/2014/12/01/new-query-feature/">https://blog.openstreetmap.org/2014/12/ … y-feature/</a></p><p>Leads me to here:<br /><a href="http://wiki.openstreetmap.org/wiki/Downloading_data">http://wiki.openstreetmap.org/wiki/Downloading_data</a></p><p>But I&#039;m not sure if that&#039;s the right path to victory here. If you can give me an example of that Feature Query tool using Online Maps, I think I&#039;ll have what I need to move forward.</p><p>Thanks again, and I hope this thread has proved instructive to others who might be reading along. <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-17T17:25:20Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2039#p2039</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2023#p2023" />
			<content type="html"><![CDATA[<p>Thanks again for your top-notch support. I&#039;ll try this out and let you know again if I run into any snags.</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-16T01:51:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2023#p2023</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2019#p2019" />
			<content type="html"><![CDATA[<p>I made a little research, and for your purposes it&#039;s best to use Foursquare.<br />Online Maps does not have classes to work with this web service, but that does not mean that you can not use it.<br />Example:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

public class GetInfoFromFoursquare:MonoBehaviour
{
    public string clientID;
    public string clientSecret;

    private void Start()
    {
        OnlineMapsControlBase.instance.OnMapClick += OnMapClick;
    }

    private void OnMapClick()
    {
        Vector2 coords = OnlineMapsControlBase.instance.GetCoords();
        OnlineMapsWWW www = new OnlineMapsWWW(&quot;https://api.foursquare.com/v2/venues/search?ll=&quot; + coords.y + &quot;,&quot; + coords.x + &quot;&amp;client_id=&quot; + clientID + &quot;&amp;client_secret=&quot; + clientSecret + &quot;&amp;v=&quot; + DateTime.Now.ToString(&quot;yyyyMMdd&quot;) + &quot;&amp;limit=1&quot;);
        Debug.Log(www.url);
        www.OnComplete += OnRequestComplete;
    }

    private void OnRequestComplete(OnlineMapsWWW www)
    {
        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log(www.error);
            return;
        }

        Debug.Log(www.text);
        OnlineMapsJSONItem json = OnlineMapsJSON.Parse(www.text);
        OnlineMapsJSONItem venue = json[&quot;response/venues/0&quot;];
        if (venue != null)
        {
            Debug.Log(venue[&quot;name&quot;]);
            Debug.Log(venue[&quot;categories/0/shortName&quot;]);
        }
    }
}</code></pre></div><p>P.S. To get id and secret you need to create an application.<br /><a href="https://foursquare.com/developers/register">https://foursquare.com/developers/register</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-15T21:49:27Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2019#p2019</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2014#p2014" />
			<content type="html"><![CDATA[<p>I see the example in the Atlas, but it&#039;s a bit hard to wrap my brain around.</p><p>This bit looks for highways on the visible portion of the map, but the first part of the query I don&#039;t understand:</p><div class="codebox"><pre><code>            // Create OSM Overpass request where highway is primary or residential
            string requestData = String.Format(&quot;node({0},{1},{2},{3});way(bn)[{4}];(._;&gt;;);out;&quot;,
            bottomRight.y, topLeft.x, topLeft.y, bottomRight.x, &quot;&#039;highway&#039;~&#039;primary|residential&#039;&quot;);</code></pre></div><p>Could I copy this example, but change the four corner coordinates to be the single point of the click? I guess I&#039;d also remove the bit at the end specifying highways? I&#039;ll try some experiments and look into the Overpass API documentation, but if you could provide a brief example that does with OSM what we were discussing with Google, I&#039;d be obliged.</p><p>Thanks again!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-15T01:47:53Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2014#p2014</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2013#p2013" />
			<content type="html"><![CDATA[<p>Well, that gets me part of the way there. It seems to work okay on buildings- I click on a dentist and I get:</p><div class="codebox"><pre><code>dentist, health, point_of_interest, establishment</code></pre></div><p>But I click on a golf course and I get:</p><div class="codebox"><pre><code>locality, political
neighborhood, political</code></pre></div><p>If I go to OpenStreetMaps and use their Query Features button, I click on a golf course and I get:</p><div class="codebox"><pre><code>Nearby features
Cycle Path #189157195
Golf Course Balboa Municipal Golf Course
Sand #317312157
Grass #317312158
Grass #317312623
Enclosing features
Golf Course Balboa Municipal Golf Course
City Boundary Los Angeles
County Boundary Los Angeles County
State Boundary California
Timezone America/Los_Angeles Timezone
Country Boundary United States of America</code></pre></div><p>So it looks like for what I&#039;m trying to do an OSM query might be the way to go. Is the means of doing so using those functions similar to what you provided for the Google Places API?</p><p>Thanks!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-15T01:19:12Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2013#p2013</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2012#p2012" />
			<content type="html"><![CDATA[<p>Sweet, I&#039;ll give that a shot. Thanks again!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-15T00:19:37Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2012#p2012</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2011#p2011" />
			<content type="html"><![CDATA[<p>I see.<br />The problem is that you are using the wrong service.<br />Google Geocoding API returns the address.<br />To find objects near the location, you need to use Google Places API.<br />Example:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class GetLocationInfo:MonoBehaviour
{
    public string key;

    private void Start()
    {
        OnlineMapsControlBase.instance.OnMapClick += OnMapClick;
    }

    private void OnMapClick()
    {
        OnlineMapsGooglePlaces.FindNearby(OnlineMapsControlBase.instance.GetCoords(), 20, key).OnComplete += OnFindNearbyComplete;
    }

    private void OnFindNearbyComplete(string response)
    {
        Debug.Log(response);
        OnlineMapsGooglePlacesResult[] results = OnlineMapsGooglePlaces.GetResults(response);
        foreach (OnlineMapsGooglePlacesResult result in results)
        {
            Debug.Log(result.name);
            Debug.Log(string.Join(&quot;, &quot;, result.types));
        }
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-14T21:10:13Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2011#p2011</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2010#p2010" />
			<content type="html"><![CDATA[<p>Trying out that code, I&#039;m still not finding what I&#039;m looking for. When I click on a nearby park, instead of being told that it&#039;s a park and the name of it, I see output like:</p><div class="codebox"><pre><code>administrative_area_level_2, political
administrative_area_level_1, political, point_of_interest, establishment
neighborhood, political</code></pre></div><p>And more like that. Do I need to make another call to find out that it&#039;s a park or a hospital or a graveyard?</p><p>Thanks again!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-14T18:18:47Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2010#p2010</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2009#p2009" />
			<content type="html"><![CDATA[<p>Thanks very much!</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-14T17:33:37Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2009#p2009</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2007#p2007" />
			<content type="html"><![CDATA[<p>Absolutely the same way as other Google API requests.</p><p>Example:<br /></p><div class="codebox"><pre><code>OnlineMapsGooglePlaceDetails.FindByPlaceID(key, placeID).OnComplete += OnPlaceDetailsComplete;

private void OnPlaceDetailsComplete(string response)
{
    OnlineMapsGooglePlaceDetailsResult result = OnlineMapsGooglePlaceDetails.GetResult(response);
    if (result == null)
    {
        Debug.LogWarning(&quot;Something wrong:\n&quot; + response);
        return;
    }
    Debug.Log(string.Join(&quot;, &quot;, result.types));
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-14T11:35:18Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2007#p2007</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2005#p2005" />
			<content type="html"><![CDATA[<p>Thanks! I&#039;m trying to figure out how to properly use OnlineMapsGooglePlaceDetails.FindByPlaceID. </p><p>The documentation says it returns a &quot;Query instance to the Google API.&quot; and when I look at it in the code, Visual Studio says it returns an OnlineMapsGooglePlaceDetails type.&nbsp; OnlineMapsGooglePlaceDetails.GetResult takes a string as a parameter, so I&#039;m not sure how to turn the OnlineMapsGooglePlaceDetails return value from FindByPlaceID into a string I can pass into GetResult. What am I missing here?</p>]]></content>
			<author>
				<name><![CDATA[Quidam]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=76</uri>
			</author>
			<updated>2017-03-14T01:43:49Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2005#p2005</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FindLocationNameExample and OnlineMapsGoogleGeocodingResult]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2003#p2003" />
			<content type="html"><![CDATA[<p>The response contains «place_id».<br />You need to make a new request to Google Places API to find out detailed information about the object.<br />OnlineMapsGooglePlaceDetails.FindByPlaceID<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsGooglePlaceDetails.html#a372fc11e600f9e17d1a441b9795d0c1d">http://infinity-code.com/doxygen/online … b9795d0c1d</a></p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-03-13T19:54:30Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2003#p2003</id>
		</entry>
</feed>
