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;
}