Пример #1
0
        public void ShowCluster(CKCluster cluster, bool animated)
        {
            MKMapRect mapRect = MKMapRect.Null;

            foreach (var annoation in cluster.Annotations)
            {
                mapRect = MKMapRectByAddingPoint(mapRect, MKMapPoint.FromCoordinate(annoation.Coordinate));
            }
            _internalMap.SetVisibleMapRect(mapRect, animated);
        }
Пример #2
0
        public static void ShowCluster(this MKMapView map, CKCluster cluster, UIEdgeInsets insets, bool animated)
        {
            MKMapRect zoomRect = MKMapRect.Null;

            foreach (var annotation in cluster.Annotations)
            {
                var pointRect = new MKMapRect();
                pointRect.Origin = MKMapPoint.FromCoordinate(annotation.Coordinate);
                pointRect.Size   = new MKMapSize(0.1d, 0.1d);
                zoomRect         = MKMapRect.Union(zoomRect, pointRect);
            }

            map.SetVisibleMapRect(zoomRect, insets, animated);
        }
        public MKMapView setMapRegion(MKMapView map)
        {
            MKMapRect zoomRect = new MKMapRect(double.PositiveInfinity, double.PositiveInfinity, 0, 0);

            foreach (MKAnnotation annotation in map.Annotations)
            {
                if (annotation.Coordinate.Latitude != 0)
                {
                    MKMapPoint annotationPoint = MKMapPoint.FromCoordinate(annotation.Coordinate);
                    MKMapRect  pointRect       = new MKMapRect(annotationPoint.X, annotationPoint.Y, 0.1, 0.1);
                    zoomRect = MKMapRect.Union(zoomRect, pointRect);
                }
            }
            map.SetVisibleMapRect(zoomRect, new UIEdgeInsets(40, 20, 20, 20), true);

            return(map);
        }
        protected override void DataSourceUpdated(WebDataSource oldDataSource, WebDataSource newDataSource)
        {
            if (mapView.Overlays != null)
            {
                mapView.RemoveOverlays(mapView.Overlays);
            }

            var representation = (XIMapViewWebDocumentRepresentation)newDataSource?.Representation;

            if (representation == null || !representation.LocationIsValid)
            {
                return;
            }

            if (representation.Polyline == null)
            {
                var coordinate = representation.Location.ToCoordinate();
                AddLocationAnnotation(coordinate);
                mapView.Region = MKCoordinateRegion.FromDistance(coordinate, 15000, 15000);
            }
            else
            {
                var coords = representation.Polyline.Value.ToCoordinates();
                for (var i = 0; i < coords.Length; i++)
                {
                    AddLocationAnnotation(
                        coords [i],
                        representation.Polyline,
                        i);
                }

                var mkpolyline = MKPolyline.FromCoordinates(coords);
                mapView.AddOverlay(mkpolyline);
                mapView.SetVisibleMapRect(
                    mkpolyline.BoundingMapRect,
                    new NSEdgeInsets(45, 35, 35, 35),
                    false);
            }
        }