Example #1
0
        public void AddItems([NotNull] List <ClusterItem> clusterItems)
        {
            if (clusterItems == null)
            {
                throw new ArgumentNullException("clusterItems");
            }

            if (clusterItems.Count == 0)
            {
                throw new ArgumentException("Value cannot be an empty collection.", "clusterItems");
            }

            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() =>
                {
                    var ajoItems = clusterItems.ToJavaList(x => new ClusterItem(x.Position, x.Title, x.Snippet).ToAJO());
                    _clusterManagerAJO.Call("addItems", ajoItems);
                    AndroidCluster();
                });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            var itemsToSerialize = clusterItems.ConvertAll(item => item.ToDictionary());
            _googleMapsViewClusterManagerAddItems(_clusterManagerPtr, Json.Serialize(itemsToSerialize));
#endif
        }
Example #2
0
        public ClusterManager([NotNull] GoogleMapsView googleMapsView)
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (googleMapsView == null)
            {
                throw new ArgumentNullException("googleMapsView");
            }

            _googleMapsView = googleMapsView;

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() =>
                {
                    _clusterManagerAJO = new AndroidJavaObject(ClusterManagerClass, JniToolkitUtils.Activity, _googleMapsView.GoogleMapAJO);
                    _googleMapsView.GoogleMapAJO.Call("setOnCameraIdleListener", _clusterManagerAJO);
                });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            _clusterManagerPtr = _createGoogleMapsViewClusterManager(googleMapsView.MapPtr);
#endif
        }
Example #3
0
        public void AddItem([NotNull] ClusterItem clusterItem)
        {
            if (clusterItem == null)
            {
                throw new ArgumentNullException("clusterItem");
            }

            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() =>
                {
                    _clusterManagerAJO.Call("addItem", clusterItem.ToAJO());
                    AndroidCluster();
                });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            _googleMapsViewClusterManagerAddSingleItem(_clusterManagerPtr, Json.Serialize(clusterItem.ToDictionary()));
#endif
        }
Example #4
0
        public void Show(Rect rect, [CanBeNull] Action onMapReady = null)
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() =>
                {
                    _ajo.Call("show",
                              (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height,
                              _options.AJO, new OnMapReadyCallbackProxy(onMapReady));
                    GoogleMapsSceneHelper.Instance.Register(this);
                });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            rect = HackForIphone6Plus(rect);

            if (_mapPtr.IsNonZero())
            {
                var options = Json.Serialize(_options.ToDictionary());
                _googleMapsViewShow(_mapPtr, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height, options);
                if (onMapReady != null)
                {
                    onMapReady();
                }

                GoogleMapsSceneHelper.Instance.Register(this);
            }
#endif
        }
		void HandleShow()
		{
			foreach (var mapView in _activeMaps)
			{
				if (mapView.CachedVisibilityHack)
				{
					mapView.IsVisible = true;
				}
				
				mapView.GoogleMapViewAJO.Call("onStart");
				mapView.GoogleMapViewAJO.Call("onResume");
				JniToolkitUtils.RunOnUiThread(() => mapView.ImmersiveModeAndroidHack());
			}
		}
Example #6
0
        static void Launch(int request, Action <AndroidJavaObject> intentAction = null)
        {
            InitGoogleApi();

            var intent = new AndroidJavaObject("android.content.Intent", JniToolkitUtils.Activity, JniToolkitUtils.ClassForName(PickerActivityClass));

            intent.CallAJO(PutExtraMethod, EXTRAS_PICKER_TYPE, request);
            intent.CallAJO("addFlags", FLAG_NO_ANIMATION);
            if (intentAction != null)
            {
                intentAction(intent);
            }
            JniToolkitUtils.StartActivity(intent);
        }
Example #7
0
        public GoogleMapsView([CanBeNull] GoogleMapsOptions options)
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            _options = options ?? new GoogleMapsOptions();

            GoogleMapsSceneHelper.Init();
            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() => { _ajo = new AndroidJavaObject(ClassName, JniToolkitUtils.Activity); });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            _mapPtr = _createGoogleMapsView();
#endif
        }
Example #8
0
        public void ClearItems()
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() =>
                {
                    _clusterManagerAJO.Call("clearItems");
                    AndroidCluster();
                });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            _googleMapsViewClusterManagerClearItems(_clusterManagerPtr);
#endif
        }
Example #9
0
        public void SetRect(Rect rect)
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() => _ajo.Call("setRect",
                                                              (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height));
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            rect = HackForIphone6Plus(rect);

            if (_mapPtr.IsNonZero())
            {
                _googleMapsViewSetRect(_mapPtr, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
            }
#endif
        }
Example #10
0
        public GoogleMapsView([CanBeNull] GoogleMapsOptions options)
        {
            if (GoogleMapUtils.IsPlatformNotSupported)
            {
                return;
            }

            _options = options ?? new GoogleMapsOptions();

            if (GoogleMapUtils.IsAndroid)
            {
                JniToolkitUtils.RunOnUiThread(() => { _ajo = new AndroidJavaObject(ClassName, JniToolkitUtils.Activity); });
            }

#if UNITY_IOS && !DISABLE_IOS_GOOGLE_MAPS
            if (GoogleMapsViewSettings.IosApiKey == GoogleMapsViewSettings.IOS_KEY_PLACEHOLDER || string.IsNullOrEmpty(GoogleMapsViewSettings.IosApiKey))
            {
                Debug.LogError("The provided API key is incorrect. " + FixApiKeyMessage);
            }

            _googleMapsViewInit(GoogleMapsViewSettings.IosApiKey.Trim());
            _mapPtr = _createGoogleMapsView();
#endif
        }