Пример #1
0
 void AddClusterItems()
 {
     if (_clusterManager != null)
     {
         _clusterManager.AddItems(DemoUtils.DeserializeClusterMarkers(markerClusterData.text));
     }
 }
Пример #2
0
        private void ReadJson()
        {
            Stream stream = Resources.OpenRawResource(Resource.Raw.radar_search);
            var    items  = ItemReader.StreamToClusterMarker(stream);

            clusterManager.AddItems(items);
        }
Пример #3
0
        private void AddClusterItems(Location currentLocation)
        {
            var items = new List <ClusterItem>();

            // Add current location to the cluster list
            var currentMarker = new MarkerOptions();
            var me            = new LatLng(currentLocation.Latitude, currentLocation.Longitude);

            currentMarker.SetPosition(me);
            var meMarker = new CircleOptions();

            meMarker.InvokeCenter(me);
            meMarker.InvokeRadius(32);
            meMarker.InvokeStrokeWidth(0);
            meMarker.InvokeFillColor(ContextCompat.GetColor(BaseContext, Android.Resource.Color.HoloBlueLight));
            _googleMap.AddCircle(meMarker);
            items.Add(new ClusterItem(currentLocation.Latitude, currentLocation.Longitude));

            // Create a log. spiral of markers to test clustering
            for (int i = 0; i < 20; ++i)
            {
                var t = i * Math.PI * 0.33f;
                var r = 0.005 * Math.Exp(0.1 * t);
                var x = r * Math.Cos(t);
                var y = r * Math.Sin(t);
                items.Add(new ClusterItem(currentLocation.Latitude + x, currentLocation.Longitude + y));
            }
            _clusterManager.AddItems(items);
        }
Пример #4
0
        private void readItems()
        {
            Stream        inputStream = Resources.OpenRawResource(Resource.Raw.radar_search);
            List <MyItem> items       = new MyItemReader().read(inputStream);

            mClusterManager.AddItems(items);
        }
        private void AddRandomClusterItems(ClusterManager clusterManager)
        {
            LatLngBounds germany = new LatLngBounds(new LatLng(47.77083, 6.57361), new LatLng(53.35917, 12.10833));

            int buffer       = 10000;
            var clusterItems = new List <SampleClusterItem>(buffer);

            for (int i = 0; i < buffer; i++)
            {
                clusterItems.Add(RandomLocationGenerator.Generate(germany));
            }
            clusterManager.AddItems(clusterItems);
            clusterItems.Clear();
        }
Пример #6
0
        async Task SetMapStationPins(Station[] stations, float alpha = 1)
        {
            var stationsToUpdate = stations.Where(station => {
                ClusterMarkerOptions marker;
                var stats = station.Locked ? string.Empty : station.BikeCount + "|" + station.EmptySlotCount;
                if (existingMarkers.TryGetValue(station.Id, out marker))
                {
                    if (marker.Options.Snippet == stats && !showedStale)
                    {
                        return(false);
                    }
                    clusterManager.RemoveItem(marker);
                }
                return(true);
            }).ToList();

            var w = (int)Math.Round(TypedValue.ApplyDimension(ComplexUnitType.Dip, 32, Resources.DisplayMetrics));
            var h = (int)Math.Round(TypedValue.ApplyDimension(ComplexUnitType.Dip, 34, Resources.DisplayMetrics));

            var pins = await Task.Run(() => stationsToUpdate.ToDictionary(station => station.Id, station => {
                if (station.Locked)
                {
                    return(BitmapDescriptorFactory.FromBitmap(pinFactory.GetClosedPin(w, h)));
                }
                var ratio = (float)TruncateDigit(station.BikeCount / ((float)station.Capacity), 2);
                return(BitmapDescriptorFactory.FromFile(pinFactory.GetPin(ratio,
                                                                          station.BikeCount,
                                                                          w, h,
                                                                          alpha: alpha)));
            }));

            var clusterItems = new List <ClusterMarkerOptions> ();

            foreach (var station in stationsToUpdate)
            {
                var pin = pins [station.Id];

                var markerOptions = new MarkerOptions()
                                    .SetTitle(station.Id + "|" + station.Name)
                                    .SetSnippet(station.Locked ? string.Empty : station.BikeCount + "|" + station.EmptySlotCount)
                                    .SetPosition(new Android.Gms.Maps.Model.LatLng(station.Location.Lat, station.Location.Lon))
                                    .SetIcon(pin);
                var markerItem = new ClusterMarkerOptions(markerOptions);
                existingMarkers [station.Id] = markerItem;
                clusterItems.Add(markerItem);
            }
            clusterManager.AddItems(clusterItems);
            clusterManager.Cluster();
        }
        private void AddClusterItems(GoogleMap map, HelperHomeModel h)
        {
            var items = new List <MyItem>();

            // Add current location to the cluster list
            var currentMarker = new MarkerOptions();
            var me            = new LatLng(h.Latitude, h.Longitude);

            currentMarker.SetPosition(me);
            var meMarker = new CircleOptions();

            meMarker.InvokeCenter(me);
            meMarker.InvokeRadius(32);
            meMarker.InvokeStrokeWidth(10);
            meMarker.InvokeFillColor(ContextCompat.GetColor(Context, Android.Resource.Color.HoloRedLight));
            map.AddCircle(meMarker);
            items.Add(new MyItem(h.Latitude, h.Longitude));

            // Create a log. spiral of markers to test clustering
            for (int i = 1; i < customMap.helperList.Count; i++)
            {
                var hi = customMap.helperList.ElementAt(i);
                var t  = i * Math.Pi * 0.33f;
                var r  = 0.005 * Math.Exp(0.1 * t);
                var x  = r * Math.Cos(t);
                var y  = r * Math.Sin(t);
                items.Add(new MyItem(hi.Latitude + x, hi.Longitude + y));
            }
            mClusterManager.AddItems(items);
            /*****************************************************************/

            // Set some lat/lng coordinates to start with.

            /*double lat = 51.5145160;
             * double lng = -0.1270060;
             *
             * // Add ten cluster items in close proximity, for purposes of this example.
             * for (int i = 1; i < customMap.helperList.Count; i++)
             * {
             *
             *  var h = customMap.helperList.ElementAt(i);
             *  double offset = i / 60d;
             *  lat = h.Latitude + offset;
             *  lng = h.Longitude + offset;
             *  MyItem offsetItem = new MyItem(lat, lng);
             *  mClusterManager.AddItem(offsetItem);
             *
             * }*/
        }
Пример #8
0
        private void addClusterItems(ClusterManager clusterManager)
        {
            Stream        inputStream = Resources.OpenRawResource(Resource.Raw.radar_search);
            List <MyItem> items;

            try
            {
                items = new MyItemReader().read(inputStream);
                clusterManager.AddItems(items);
            }
            catch (JSONException e)
            {
                Toast.MakeText(this, "Problem reading list of markers.", ToastLength.Long).Show();
                e.PrintStackTrace();
            }
        }
Пример #9
0
        private void AddClusterItems()
        {
            double lat = 63.430515;
            double lng = 10.395053;

            List <ClusterItem> items = new List <ClusterItem>();

            for (var i = 0; i < 10; i++)
            {
                double offset = i / 60d;
                lat = lat + offset;
                lng = lng + offset;

                var item = new ClusterItem(lat, lng);
                items.Add(item);
            }

            _clusterManager.AddItems(items);
        }
        private void UpdatePins()
        {
            var mapTile  = (MapTile)Element;
            var pinItems = mapTile.PinList;

            ClusterManager.ClearItems();
            NativeMap.Clear();

            var clusterItems = pinItems.Select(i => new ClusterItem(i)).ToList();

            ClusterManager.AddItems(clusterItems);

            ClusterManager.Cluster();

            if (LocationMarkerOptions.Position != null)
            {
                LocationMarker = NativeMap.AddMarker(LocationMarkerOptions);
            }

            UpdateLocationPinPosition();
        }