コード例 #1
0
ファイル: PlacePicker.cs プロジェクト: james4787/Forewind_Pro
        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
        }
コード例 #2
0
        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);
                    }
                }
            }
        }
コード例 #3
0
        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
        }