public static void ShowPlacePicker([NotNull] Action <Place> onPlacePicked, [NotNull] Action <string> onFailure) { if (GoogleMapUtils.IsPlatformNotSupported) { return; } if (onPlacePicked == null) { throw new ArgumentNullException("onPlacePicked"); } if (onFailure == null) { throw new ArgumentNullException("onFailure"); } _onPlacePicked = onPlacePicked; _onFailure = onFailure; GooglePlacesSceneHelper.Init(); if (GoogleMapUtils.IsAndroid) { PlacePickerActivityUtils.LaunchPlacePicker(); } #if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS _googleMapsShowPlacePicker(); #endif }
internal static void Init() { lock (InitLock) { if (ReferenceEquals(_instance, null)) { var instances = FindObjectsOfType <GooglePlacesSceneHelper>(); var className = typeof(GooglePlacesSceneHelper).Name; if (instances.Length > 1) { Debug.LogError(className + " Something went really wrong " + " - there should never be more than 1 " + className + " Reopening the scene might fix it."); } else if (instances.Length == 0) { var singleton = new GameObject(); _instance = singleton.AddComponent <GooglePlacesSceneHelper>(); singleton.name = className; DontDestroyOnLoad(singleton); Debug.Log("[Singleton] An _instance of " + className + " is needed in the scene, so '" + singleton.name + "' was created with DontDestroyOnLoad."); } else { Debug.Log("[Singleton] Using _instance already created: " + _instance.gameObject.name); } } } }
public static void ShowPlaceAutocomplete( [NotNull] Action <Place> onPlacePicked, [NotNull] Action <string> onFailure, [GoogleMapsAndroidOnly] Mode mode = Mode.Fullscreen, AutocompleteFilter filter = AutocompleteFilter.None, string countryCode = null, LatLngBounds boundsBias = null) { if (onPlacePicked == null) { throw new ArgumentNullException("onPlacePicked"); } if (onFailure == null) { throw new ArgumentNullException("onFailure"); } if (GoogleMapUtils.IsPlatformNotSupported) { return; } _onPlacePicked = onPlacePicked; _onFailure = onFailure; GooglePlacesSceneHelper.Init(); if (GoogleMapUtils.IsAndroid) { PlacePickerActivityUtils.LaunchPlaceAutocomplete(mode, filter, countryCode, boundsBias); } #if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS string bounds = null; if (boundsBias != null) { bounds = Json.Serialize(boundsBias.ToDictionary()); } _googleMapsShowPlaceAutocomplete((int)mode, (int)filter, countryCode, bounds); #endif }