Пример #1
0
        void AddCluster()
        {
            var googleMapView = mapView;             //use the real mapview init'd somewhere else instead of this
            var iconGenerator = new GMUDefaultClusterIconGenerator();
            var algorithm     = new GMUNonHierarchicalDistanceBasedAlgorithm();
            var renderer      = new GMUDefaultClusterRenderer(googleMapView, iconGenerator);

            renderer.WeakDelegate = this;

            clusterManager = new GMUClusterManager(googleMapView, algorithm, renderer);

            for (var i = 0; i <= kClusterItemCount; i++)
            {
                var lat = kCameraLatitude + extent * GetRandomNumber(-1.0, 1.0);

                var lng = kCameraLongitude + extent * GetRandomNumber(-1.0, 1.0);

                var name = $"Item {i}";

                IGMUClusterItem item = new POIItem(lat, lng, name);

                clusterManager.AddItem(item);
            }

            clusterManager.Cluster();

            clusterManager.SetDelegate(this, this);
        }
Пример #2
0
        // Randomly generates cluster items within some extent of the camera and adds them to the cluster manager.
        private void generateClusterItems()
        {
            var extent = 0.2;

            for (int index = 1; index <= kClusterItemCount; index++)
            {
                var lat  = kCameraLatitude + extent * randomScale();
                var lng  = kCameraLongitude + extent * randomScale();
                var name = $"Item {index}";
                var item = new POIItem(position: new CLLocationCoordinate2D(lat, lng), name: name);
                clusterManager.AddItem(item);
            }
        }
Пример #3
0
        public void WillRenderMarker(GMUClusterRenderer renderer, Overlay marker)
        {
            if (marker is Marker)               // Overlays sneaking in here disguised as Markers...
            {
                var myMarker = (Marker)marker;

                if (myMarker.UserData is POIItem)
                {
                    POIItem item = (POIItem)myMarker.UserData;
                    myMarker.Title = item.Name;
                }
            }
        }
 public void WillRenderMarker(GMUClusterRenderer renderer, Overlay marker)
 {
     Google.Maps.Marker gmsMarker = marker as Marker;
     if (gmsMarker.UserData.GetType() == typeof(GMUStaticCluster))
     {
         GMUStaticCluster cluster = gmsMarker.UserData as GMUStaticCluster;
         // set a custom icon or view here
     }
     else
     {
         POIItem clustItem = gmsMarker.UserData as POIItem;
         // set a custom icon or view here
     }
 }
        void UpdateAllPins()
        {
            var googleMapView = nativeMap;
            var iconGenerator = new GMUDefaultClusterIconGenerator();
            var algorithm     = new GMUNonHierarchicalDistanceBasedAlgorithm();
            GMUDefaultClusterRenderer renderer = null;

            try
            {
                renderer = new GMUDefaultClusterRenderer(googleMapView, iconGenerator);

                renderer.WeakDelegate = this;
                clusterManager        = new GMUClusterManager(googleMapView, algorithm, renderer);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            for (var i = 0; i < Map.Pins.Count; i++)
            {
                Pin pin = (Map.Pins[i] as Pin);
                var lat = pin.Position.Latitude;

                var lng = pin.Position.Longitude;

                var name = pin.Label;

                IGMUClusterItem item = new POIItem(lat, lng, name);

                clusterManager.AddItem(item);
            }

            clusterManager.Cluster();

            clusterManager.SetDelegate(this, this);
        }
Пример #6
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var googleMapView = mapView; //use the real mapview init'd somewhere else instead of this
            var iconGenerator = new GMUDefaultClusterIconGenerator();
            var algorithm     = new GMUNonHierarchicalDistanceBasedAlgorithm();
            var renderer      = new GMUDefaultClusterRenderer(googleMapView, iconGenerator);

            renderer.WeakDelegate = this;

            clusterManager = new GMUClusterManager(googleMapView, algorithm, renderer);

            JsonSerializer _serializer = new JsonSerializer()
            {
                DateTimeZoneHandling = DateTimeZoneHandling.Utc
            };

            using (HttpClient httpClient = new HttpClient(new HttpClientHandler {
                AutomaticDecompression = DecompressionMethods.GZip
            }))
            {
                Token token = null;
                httpClient.BaseAddress = new Uri(AppSettings.BaseAddress);
                FormUrlEncodedContent formUrlEncodedContent = new FormUrlEncodedContent(new Dictionary <String, String> {
                    { "client_id", AppSettings.Client_id },
                    { "client_secret", AppSettings.Client_secret },
                    { "grant_type", AppSettings.Grant_type }
                });
                using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, "/connect/token"))
                {
                    httpRequestMessage.Content = formUrlEncodedContent;
                    using (HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
                    {
                        if (httpResponseMessage.IsSuccessStatusCode == true)
                        {
                            using (System.IO.Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync())
                            {
                                using (System.IO.StreamReader streamReader = new System.IO.StreamReader(stream))
                                {
                                    using (JsonTextReader json = new JsonTextReader(streamReader))
                                    {
                                        token = _serializer.Deserialize <Token>(json);
                                    }
                                }
                            }
                        }
                    }
                }
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.token_type, token.access_token);

                using (HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("/api/v1/pl/Locations/lots"))
                {
                    if (httpResponseMessage.IsSuccessStatusCode == true)
                    {
                        using (System.IO.Stream stream = await httpResponseMessage.Content.ReadAsStreamAsync())
                        {
                            using (System.IO.StreamReader streamReader = new System.IO.StreamReader(stream))
                            {
                                using (JsonTextReader json = new JsonTextReader(streamReader))
                                {
                                    Response <Lot[]> lots = _serializer.Deserialize <Response <Lot[]> >(json);
                                    for (int i = 0; i < lots.result.Length; i++)
                                    {
                                        IGMUClusterItem item = new POIItem(lots.result[i].latitude, lots.result[i].longitude, lots.result[i].name);
                                        clusterManager.AddItem(item);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            clusterManager.Cluster();

            clusterManager.SetDelegate(this, this);
        }
        public void DidTapClusterItem(GMUClusterManager clusterManager, IGMUClusterItem clusterItem)
        {
            POIItem poitem = clusterItem as POIItem;

            Map.ClusterItemClicked(poitem);
        }