Topic: Inconsistent FindNearby Results

I'm adapting the SearchNearby example code in my project and I'm having some inconsistent behavior. Sometimes a search term I'll use will give me the markers I expect, but in many other cases I get a result set that doesn't seem to have any unifying theme. It's almost as if I'm getting a result set from a blank search- just a list of the things nearest the search focus.

Can you see anything wrong with my code? Any ideas as to what might be causing this?

        public void SearchNearby()
        {
            Debug.Log(SearchField.text);

            OnlineMapsFindPlaces.FindNearby(
                OnlineMaps.instance.position,
                4000,
                "[Key Removed for Forum Post]", // <----------------------------- Google API Key
                null,
                null,
                SearchField.text).OnComplete += OnFindComplete;
        }
        private void OnFindComplete(string s)
        {
            OnlineMapsFindPlacesResult[] results = OnlineMapsFindPlaces.GetResults(s);
            if (results == null)
            {
                Debug.Log("Error");
                Debug.Log(s);
                return;
            }

            // Clear the existing find results
            OnlineMaps.instance.RemoveAllMarkers();
            
            List<OnlineMapsMarker> markers = new List<OnlineMapsMarker>();
            foreach (OnlineMapsFindPlacesResult result in results)
            {
                // Debug.Log(result.name);
                // Debug.Log(result.location);

                OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(result.location, result.name);
                marker.OnClick += OnMarkerClick;
                markers.Add(marker);

            }

            Vector2 center;
            int zoom;
            OnlineMapsUtils.GetCenterPointAndZoom(markers.ToArray(), out center, out zoom);

            OnlineMaps.instance.position = center;
            OnlineMaps.instance.zoom = zoom + 1;
        }

Re: Inconsistent FindNearby Results

Hello.

What do you want to find?
Most likely Search Field.text contains the name of the place, right?
In this case, you use the wrong parameter (the sixth parameter is «types»).
You need to use a keyword (4) or the name (5) parameters.

https://developers.google.com/places/we … chRequests

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

3 (edited by Quidam 2016-03-09 18:44:37)

Re: Inconsistent FindNearby Results

Thanks! I wasn't paying proper attention to the different parameter types and had just copied the example code where you specifically search for a type. Now that I'm passing in my search terms through the keyword parameter things seem to be working as expected. I see now that the searches which were working were for terms that were more of a type than a name or a keyword.

I'm curious, though: if I was passing in values in the «types» parameter that weren't yielding any results, why was I getting the same list over and over? Shouldn't I have got an empty set?

Re: Inconsistent FindNearby Results

When you use an incorrect value «types», Google Places API ignores it, and looking for the result as if this parameter is not specified.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Inconsistent FindNearby Results

Is there a way to know what's considered a valid value for «types»? A list somewhere, maybe?

Re: Inconsistent FindNearby Results

https://developers.google.com/places/su … ypes?hl=en

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.