Ejemplo n.º 1
0
        public static bool Remove(CKNode node, MKAnnotation annotation)
        {
            if (CKNode.Drop(node, annotation))
            {
                return(true);
            }

            if (node.SW != null)
            {
                if (CKNode.Remove(node.NW, annotation))
                {
                    return(true);
                }

                if (CKNode.Remove(node.NE, annotation))
                {
                    return(true);
                }

                if (CKNode.Remove(node.SW, annotation))
                {
                    return(true);
                }

                if (CKNode.Remove(node.SE, annotation))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static bool Drop(CKNode node, MKAnnotation annotation)
        {
            CKPoint cur  = node.Points;
            CKPoint prev = null;

            while (cur != null)
            {
                prev = cur;
                cur  = cur.Next;

                if (cur.Annotation == annotation)
                {
                    if (prev == null)
                    {
                        node.Points = cur.Next;
                    }
                    else
                    {
                        prev.Next = cur.Next;
                    }
                    node.Count--;
                    return(true);
                }
            }

            return(false);
        }
        protected override void UpdatePushpinPosition(Route e)
        {
            MKAnnotation annotation = null;

            if (e is Route <ResponderModel> )
            {
                var responderRoute = e as Route <ResponderModel>;

                annotation = _nativeMap.Annotations
                             .OfType <ResponderAnnotation>()
                             .FirstOrDefault(a => a.Responder.Id == responderRoute.Element?.Id);
            }
            else if (e is Route <UserRole> )
            {
                annotation = _nativeMap.Annotations
                             .OfType <UserAnnotation>()
                             .FirstOrDefault();
            }

            if (annotation != null)
            {
                var newCoordinate = new CLLocationCoordinate2D
                {
                    Latitude  = e.CurrentPosition.Latitude,
                    Longitude = e.CurrentPosition.Longitude
                };

                annotation.SetCoordinate(newCoordinate);
            }
        }
Ejemplo n.º 4
0
        public void updateTrackLocation()
        {
            try {
                // no gps update yet(not on screen), -180, -180
                if (_mapView.UserLocation.Coordinate.Latitude != -180 && _mapView.UserLocation.Coordinate.Longitude != -180)
                {
                    if (_trackCoordinate.IsValid())
                    {
                        if (_trackPoint == null)
                        {
                            _trackPoint = new PointAnnotation(_trackCoordinate, "Contact", "Here");
                            _mapView.AddAnnotation(_trackPoint);
                        }

                        _userLocation = _mapView.UserLocation.Coordinate;

                        if (_userLocation.IsValid() && RouteLine != null)
                        {
                            _userLocation         = _mapView.UserLocation.Coordinate;
                            RouteLine.Points[0].X = _userLocation.Latitude;
                            RouteLine.Points[0].Y = _userLocation.Longitude;
                            RouteLine.Points[1].X = _trackCoordinate.Latitude;
                            RouteLine.Points[1].Y = _trackCoordinate.Longitude;

                            _trackPoint.Coordinate = _trackCoordinate;
                            _mapView.AddAnnotation(_trackPoint);
                            //put in line here
                            //_mapView.AddOverlay(RouteLine);

                            ZoomIn();
                        }
                        else
                        {
                            throw new Exception("_UserLocation is null");
                        }

                        //calc dist
                        if (_mapView.UserLocation != null)
                        {
                            CLLocation location = new CLLocation(_trackCoordinate.Latitude, _trackCoordinate.Longitude);
                            var        distance = Math.Round(_mapView.UserLocation.Location.Distancefrom(location), 2);
                            if (distance > 9000)
                            {
                                _distanceLbl.Text = "> 9000";
                            }
                            else
                            {
                                _distanceLbl.Text = distance.ToString();
                            }
                        }
                    }
                    ServiceHelper.instance.releaseSemaphore();
                }
            } catch (Exception e) {
                MessageHelper.showErrorMesage("Problem in updateTrackLocation " + e.Message);
            }
        }
Ejemplo n.º 5
0
		public void UpdateLocation(CLLocationCoordinate2D newLocation, bool animated){
            var span = new MKCoordinateSpan(0.1,0.1);
			var region = new MKCoordinateRegion(newLocation, span);
			_mapView.SetRegion(region, animated);
			if (_geocodeAnnotation!=null)
				_mapView.RemoveAnnotation(_geocodeAnnotation);
			_geocodeAnnotation = new MapViewAnnotation(newLocation);
			_mapView.AddAnnotationObject(_geocodeAnnotation);
		}
Ejemplo n.º 6
0
        public ClusterView(MKAnnotation annotation, string reuseIdentifier) : base(annotation, reuseIdentifier)
        {
            // Initialize
            DisplayPriority = MKFeatureDisplayPriority.DefaultHigh;
            CollisionMode   = MKAnnotationViewCollisionMode.Circle;

            // Offset center point to animate better with marker annotations
            CenterOffset = new CoreGraphics.CGPoint(0, -10);
        }
Ejemplo n.º 7
0
        public MapViewController() : base()
        {
            try {
                _trackPoint      = null;
                _trackCoordinate = new CLLocationCoordinate2D(17.731693, -102.030657);
                _userLocation    = new CLLocationCoordinate2D(17.731693, -102.030657);

                //initial
            } catch (Exception e) {
                MessageHelper.showErrorMesage("Problem in ctor of mapviewcontroller " + e.Message);
            }
        }
Ejemplo n.º 8
0
        public void UpdateLocation(CLLocationCoordinate2D newLocation, bool animated)
        {
            var span   = new MKCoordinateSpan(0.1, 0.1);
            var region = new MKCoordinateRegion(newLocation, span);

            _mapView.SetRegion(region, animated);
            if (_geocodeAnnotation != null)
            {
                _mapView.RemoveAnnotation(_geocodeAnnotation);
            }
            _geocodeAnnotation = new MapViewAnnotation(newLocation);
            _mapView.AddAnnotationObject(_geocodeAnnotation);
        }
        CustomPin GetCustomPin(MKAnnotation annotation)
        {
            var position = new Position(annotation.Coordinate.Latitude, annotation.Coordinate.Longitude);

            foreach (var pin in customPins)
            {
                if (pin.Position == position)
                {
                    return(pin);
                }
            }

            return(null);
        }
Ejemplo n.º 10
0
        public ClusterAnnotation ClusterAnnotationForOriginalAnnotation(MKAnnotation annotation)
        {
            if (annotation.GetType() != typeof(ClusterAnnotation))
            {
                foreach (var clusterAnnotation in DisplayedAnnotations())
                {
                    if (clusterAnnotation.Cluster.IsRootClusterForAnnotation(annotation))
                    {
                        return(clusterAnnotation);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 11
0
        public static bool Insert(CKNode node, MKAnnotation annotation)
        {
            var point = MKMapPoint.FromCoordinate(annotation.Coordinate);

            if (!node.Bound.Contains(point))
            {
                return(false);
            }

            if (node.Count < node.Capacity)
            {
                CKPoint tPoint = new CKPoint();
                tPoint.Annotation = annotation;
                tPoint.Point      = point;
                CKNode.Add(node, tPoint);
                return(true);
            }

            if (node.NW == null)
            {
                CKNode.Subdivide(node);
            }

            if (CKNode.Insert(node.NW, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.NE, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.SW, annotation))
            {
                return(true);
            }

            if (CKNode.Insert(node.SE, annotation))
            {
                return(true);
            }

            return(false);
        }
            protected override void Dispose(bool disposing)
            {
                if (disposing)
                {
                    if (_MapView != null)
                    {
                        _MapView.Dispose();
                        _MapView = null;
                    }

                    if (GeocodeAnnotation != null)
                    {
                        GeocodeAnnotation.Dispose();
                        GeocodeAnnotation = null;
                    }
                }

                base.Dispose(disposing);
            }
Ejemplo n.º 13
0
        // Animate Annotation on the map between retrieving positions
        private void AnimateAnnotationOnMap(MKAnnotation annotationToUpdate, Position newPosition)
        {
            var annotationToUpdateView = ViewForAnnotation(annotationToUpdate) as PinAnnotationView;

            if (annotationToUpdateView == null)
            {
                // crashed the app once, not sure what caused it
                return;
            }

            annotationToUpdateView.RefreshPinImage();

            var animationOptions = UIViewAnimationOptions.CurveLinear | UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.AllowAnimatedContent;

            Animate(5, 0, animationOptions, () =>
            {
                annotationToUpdate.SetCoordinate(new CLLocationCoordinate2D(newPosition.Latitude, newPosition.Longitude));
            }, () => {});
        }
Ejemplo n.º 14
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            UITouch aTouch   = (UITouch)touches.AnyObject;
            PointF  location = aTouch.LocationInView(this);

            var coordinate = _mapView.ConvertPoint(location, this);

            if (this.HasPoint)
            {
                _mapView.RemoveAnnotation(point);
                point = new PointAnnotation(coordinate, "Meeting Place", "Here");
                _mapView.AddAnnotation(point);
            }
            else
            {
                point = new PointAnnotation(coordinate, "Meeting Place", "Here");
                _mapView.AddAnnotation(point);
                this.HasPoint = true;
            }
        }
Ejemplo n.º 15
0
 public static void Insert(CKTree tree, MKAnnotation annotation)
 {
     CKNode.Insert(tree.Root, annotation);
 }
Ejemplo n.º 16
0
 public new void AddAnnotations(MKAnnotation[] anns)
 {
     _allAnnotations.AddRange(anns);
     PopulateMap();
 }
Ejemplo n.º 17
0
 public void RemoveAnnotation(MKAnnotation ann)
 {
     _allAnnotations.Remove(ann);
     PopulateMap();
 }
Ejemplo n.º 18
0
 public void SetAnnotations(MKAnnotation[] anns)
 {
     _allAnnotations = new List<MKAnnotation>(anns);
     PopulateMap();
 }
Ejemplo n.º 19
0
 public new void AddAnnotation(MKAnnotation ann)
 {
     _allAnnotations.Add(ann);
     PopulateMap();
 }
Ejemplo n.º 20
0
 public AnnotationCluster(MKAnnotation annotation)
     : base()
 {
     _annotations = new List<MKAnnotation>();
     _annotations.Add(annotation);
 }
Ejemplo n.º 21
0
 public void RemoveAnnotations(MKAnnotation[] anns)
 {
     foreach (MKAnnotation ann in anns)
     {
         _allAnnotations.Remove(ann);
     }
     PopulateMap();
 }
Ejemplo n.º 22
0
 public virtual void AddAnnotation(MKAnnotation annotation)
 {
     _annotations.Add(annotation);
 }
Ejemplo n.º 23
0
 public void AddNonClusteredAnnotation(MKAnnotation annotation)
 {
     base.AddAnnotation(annotation);
 }
Ejemplo n.º 24
0
        private void UpdateTaxiLocation(TaxiLocation value)
        {
            if (_taxiLocationPin != null && value == null)
            {
                RemoveAnnotation(_taxiLocationPin);
                _taxiLocationPin = null;

                return;
            }

            if (value == null)
            {
                return;
            }

            var showOrientedPins = ViewModel.Settings.ShowOrientedPins && value.CompassCourse.HasValue;

            _automatedMapChanged = true;

            // Update Marker and Animate it to see it move on the map
            if (_taxiLocationPin != null && value.Longitude.HasValue && value.Latitude.HasValue)
            {
                var taxiLocationPin = (AddressAnnotation)_taxiLocationPin;

                taxiLocationPin.Degrees = value.CompassCourse ?? 0;

                taxiLocationPin.ShowOrientation = showOrientedPins;

                AnimateAnnotationOnMap(taxiLocationPin, new Position {
                    Latitude = value.Latitude.Value, Longitude = value.Longitude.Value
                });

                return;
            }

            // Create Marker the first time
            var coord = new CLLocationCoordinate2D(0, 0);

            var vehicleLatitude  = value.Latitude ?? 0;
            var vehicleLongitude = value.Longitude ?? 0;

            // ReSharper disable CompareOfFloatsByEqualityOperator
            if (vehicleLatitude != 0 && vehicleLongitude != 0 && value.VehicleNumber.HasValue())
            // ReSharper enable CompareOfFloatsByEqualityOperator
            {
                // Refresh vehicle position
                coord = new CLLocationCoordinate2D(vehicleLatitude, vehicleLongitude);
            }

            _taxiLocationPin = new AddressAnnotation(
                coord,
                AddressAnnotationType.Taxi,
                Localize.GetValue("TaxiMapTitle"),
                value.VehicleNumber,
                _useThemeColorForPickupAndDestinationMapIcons,
                _showAssignedVehicleNumberOnPin,
                null,
                value.Market,
                value.CompassCourse ?? 0,
                showMedallionOnStart: true,
                showOrientation: showOrientedPins);

            AddAnnotation(_taxiLocationPin);
            SetNeedsDisplay();
        }
Ejemplo n.º 25
0
 public void AddAnnotation(MKAnnotation [] annotations)
 {
     AddAnnotationObjects (annotations);
 }
Ejemplo n.º 26
0
 public void RemoveNonClusteredAnnotation(MKAnnotation annotation)
 {
     base.RemoveAnnotation(annotation);
 }
Ejemplo n.º 27
0
		public static RectangleF GetSize(MKAnnotation annotation, List<Block> blocks, RectangleF bounds)
		{			
			var size = new SizeF(0,0);
			
			float diam = 47 / 2;
			float width = size.Width + 2 * 3 + diam + 3;
			float height = size.Height + 8;			
			
			try
			{
				string title = annotation.Title;
				string subTitle = annotation.Subtitle;				
				
				if (title != null)
				{				
					float subTitleHeightPadY = 3;
					float dimWidth = 0;	
					
					using (var nss = new NSString (title)){
						UIFont font = UIFont.SystemFontOfSize(17);
						var dim = nss.StringSize (font, bounds.Width - diam - 3 * 3, UILineBreakMode.TailTruncation);
						var placement = new RectangleF(3, subTitleHeightPadY, dim.Width, dim.Height);						
						
						var block = new Block()
						{
							Font = font,
							Value = title,
							LineBreakMode = UILineBreakMode.TailTruncation,
							TextColor = UIColor.White,
							Bounds = placement,
						};
						
						blocks.Add(block);
						
						dimWidth = dim.Width;
						subTitleHeightPadY += dim.Height;
					}
					subTitleHeightPadY += 3;
					
					if (subTitle != null)
					{
						using (var nss = new NSString (subTitle)){
							UIFont font = UIFont.SystemFontOfSize(12);
							var dim = nss.StringSize (font, bounds.Width - diam - 3 * 3, UILineBreakMode.TailTruncation);						
							var placement = new RectangleF(3, subTitleHeightPadY, dim.Width, dim.Height);
							
							var block = new Block()
							{
								Font = font,
								Value = subTitle,
								LineBreakMode = UILineBreakMode.TailTruncation,
								TextColor = UIColor.White,
								Bounds = placement,
							};
						
							blocks.Add(block);
							
							dimWidth = Math.Max(dimWidth, dim.Width);
							subTitleHeightPadY += dim.Height;
						}
					}
					
					subTitleHeightPadY += 3;
					size = new SizeF(dimWidth, subTitleHeightPadY); 
				}
							
				width = size.Width + 2 * 3 + diam + 3;
				height = size.Height + 23;
			
			}
			catch (Exception ex)
			{
				Util.LogException("GetSize", ex);
			}
			return new RectangleF(5, 2, width, height);			
		}
Ejemplo n.º 28
0
		protected void RemoveLocation(MKAnnotation a, int i)
		{
			Pins.Remove(i);
			mapView.RemoveAnnotation(a);
		}
Ejemplo n.º 29
0
 public static void Remove(CKTree tree, MKAnnotation annotation)
 {
     CKNode.Remove(tree.Root, annotation);
 }
Ejemplo n.º 30
0
 public void Start(MKAnnotation annotation)
 {
     UserInteractionEnabled = false;
     Start(new Flyover(annotation.Coordinate));
 }
Ejemplo n.º 31
0
 public void AddAnnotation(MKAnnotation annotation)
 {
     AddAnnotationObject(annotation);
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="annotation"></param>
 public MapPointAnnotation(MKAnnotation annotation)
 {
     MapPoint   = MKMapPoint.FromCoordinate(annotation.Coordinate);
     Annotation = annotation;
 }
Ejemplo n.º 33
0
 public bool IsRootClusterForAnnotation(MKAnnotation annotation)
 {
     return(Annotation.Annotation == annotation || _leftChild.IsRootClusterForAnnotation(annotation) || _rightChild.IsRootClusterForAnnotation(annotation));
 }
Ejemplo n.º 34
0
 public void AddAnnotation(MKAnnotation annotation)
 {
     AddAnnotationObject (annotation);
 }