/* INFINITY CODE 2013-2016 */ /* http://www.infinity-code.com */ using System.Collections.Generic; using UnityEngine; namespace InfinityCode.OnlineMapsExamples { [AddComponentMenu("Infinity Code/Online Maps/Examples (API Usage)/FindPlacesExample")] public class FindPlaces : MonoBehaviour { // new Vector2(/*121.022847f*/,/*14.631309f*/) Vector2 gpsLocation = OnlineMaps.instance.GetComponent().position;//added code private void Start() { OnlineMapsFindPlaces.FindNearby( gpsLocation,//<----added code 1000, , // <----------------------------- remove my Google API Key "jollibee", null, "restaurant").OnComplete += OnComplete; } private void OnComplete(string s) { OnlineMapsFindPlacesResult[] results = OnlineMapsFindPlaces.GetResults(s); if (results == null) { Debug.Log("Error"); Debug.Log(s); return; } List markers = new List(); foreach (OnlineMapsFindPlacesResult result in results) { Debug.Log(result.name); Debug.Log(result.location); OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(result.location, result.name); markers.Add(marker); } Vector2 center; int zoom; OnlineMapsUtils.GetCenterPointAndZoom(markers.ToArray(), out center, out zoom); OnlineMaps.instance.position = center; OnlineMaps.instance.zoom = zoom + 1; //Added Codes OnlineMaps api = OnlineMaps.instance; // Add OnClick events to static markers foreach (OnlineMapsMarker marker in api.markers) //added codes { marker.OnClick += OnMarkerClick; } } private void OnMarkerClick(OnlineMapsMarkerBase marker) //added codes { // Show in console marker label. Debug.Log(marker.label); Application.LoadLevel("MainScene"); } } }