Example #1
0
        /// <summary>
        /// Creates a new route tracker animator.
        /// </summary>
        /// <param name="mapView">The mapview.</param>
        /// <param name="routeTracker">The tracker tracking the route.</param>
        /// <param name="restartAfterTouch">The time in second to wait before resuming tracking after the mapview is touched.</param>
        /// <param name="defaultZoom">The default zoom.</param>
        public RouteTrackerAnimator(IMapView mapView, RouteTracker routeTracker, Second restartAfterTouch, float defaultZoom)
        {
            this.MinZoom     = 18;
            this.MaxZoom     = 30;
            this.DefaultZoom = defaultZoom;

            _mapView         = mapView;
            _animator        = new MapViewAnimator(mapView);
            _routeTracker    = routeTracker;
            _minimumTrackGap = new TimeSpan(0, 0, 0, 0, 500).Ticks;

            this.RestartAfterTouch = restartAfterTouch;

            _mapView.MapTouched += MapViewMapTouched;
        }
Example #2
0
        /// <summary>
        /// Diposes of all resources associated with this object.
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (disposing == true)
            {
                //someone wants the deterministic release of all resources
                //Let us release all the managed resources
            }
            else
            {
                // Do nothing, no one asked a dispose, the object went out of
                // scope and finalized is called so lets next round of GC
                // release these resources
            }

            // Release the unmanaged resource in any case as they will not be
            // released by GC
            this._cacheRenderer = null;
            if (this._offScreenBuffer != null)
            { // dispose of the map view surface.
                this._offScreenBuffer.Dispose();
                this._offScreenBuffer = null;
            }
            if (this._onScreenBuffer != null)
            { // dispose of the map view surface.
                this._onScreenBuffer.Dispose();
                this._onScreenBuffer = null;
            }
            if (this._mapViewAnimator != null)
            {
                _mapViewAnimator.Stop();
                _mapViewAnimator = null;
            }
            if (this._map != null)
            {
                this._map = null;
            }

            this._scaleGestureDetector  = null;
            this._tagGestureDetector    = null;
            this._moveGestureDetector   = null;
            this._rotateGestureDetector = null;
        }
        /// <summary>
        /// Creates a new route tracker animator.
        /// </summary>
        /// <param name="mapView">The mapview.</param>
        /// <param name="routeTracker">The tracker tracking the route.</param>
        /// <param name="restartAfterTouch">The time in second to wait before resuming tracking after the mapview is touched.</param>
        public RouteTrackerAnimator(IMapView mapView, RouteTracker routeTracker, Second restartAfterTouch)
        {
            this.MinZoom = 16;
            this.MaxZoom = 30;
            this.DefaultZoom = 17.5f;

            _mapView = mapView;
            _animator = new MapViewAnimator(mapView);
            _routeTracker = routeTracker;
            _minimumTrackGap = new TimeSpan (0, 0, 0, 0, 500).Ticks;

            this.RestartAfterTouch = restartAfterTouch;

            _mapView.MapTouched += MapViewMapTouched;
        }
Example #4
0
 /// <summary>
 /// Registers the animator.
 /// </summary>
 /// <param name="mapViewAnimator">Map view animator.</param>
 internal void RegisterAnimator(MapViewAnimator mapViewAnimator)
 {
     _mapViewAnimator = mapViewAnimator;
 }
Example #5
0
 /// <summary>
 /// Registers the animator.
 /// </summary>
 /// <param name="mapViewAnimator">Map view animator.</param>
 public void RegisterAnimator(MapViewAnimator mapViewAnimator)
 {
     _mapViewAnimator = mapViewAnimator;
 }
Example #6
0
        /// <summary>
        /// Initialize the specified defaultMapCenter, defaultMap, defaultMapTilt and defaultMapZoom.
        /// </summary>
        /// <param name="defaultMapCenter">Default map center.</param>
        /// <param name="defaultMap">Default map.</param>
        /// <param name="defaultMapTilt">Default map tilt.</param>
        /// <param name="defaultMapZoom">Default map zoom.</param>
        public void Initialize(GeoCoordinate defaultMapCenter, Map defaultMap, Degree defaultMapTilt, float defaultMapZoom)
        {
            // set clip to bounds to prevent objects from being rendered/show outside of the mapview.
            this.ClipsToBounds = true;

            _mapCenter = defaultMapCenter;
            _map       = defaultMap;
            _mapTilt   = defaultMapTilt;
            _mapZoom   = defaultMapZoom;

            _doubleTapAnimator = new MapViewAnimator(this);

            this.BackgroundColor        = UIColor.White;
            this.UserInteractionEnabled = true;

            _markers = new List <MapMarker> ();

            if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0))
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                panGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                panGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                pinchGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                pinchGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => {
                    return(true);
                };
                // TODO: workaround for xamarin bug, remove later!
                rotationGesture.ShouldRequireFailureOf   = (a, b) => { return(false); };
                rotationGesture.ShouldBeRequiredToFailBy = (a, b) => { return(false); };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                // TODO: workaround for xamarin bug, remove later!
//				singleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				singleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                // TODO: workaround for xamarin bug, remove later!
//				doubleTapGesture.ShouldRequireFailureOf = (a, b) => { return false; };
//				doubleTapGesture.ShouldBeRequiredToFailBy = (a, b) => { return false; };

                //singleTapGesture.RequireGestureRecognizerToFail (doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }
            else
            {
                var panGesture = new UIPanGestureRecognizer(Pan);
                panGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(panGesture);

                var pinchGesture = new UIPinchGestureRecognizer(Pinch);
                pinchGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(pinchGesture);

                var rotationGesture = new UIRotationGestureRecognizer(Rotate);
                rotationGesture.ShouldRecognizeSimultaneously += (UIGestureRecognizer r, UIGestureRecognizer other) => { return(true); };
                this.AddGestureRecognizer(rotationGesture);

                var singleTapGesture = new UITapGestureRecognizer(SingleTap);
                singleTapGesture.NumberOfTapsRequired = 1;
                //singleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //singleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslySingle;

                var doubleTapGesture = new UITapGestureRecognizer(DoubleTap);
                doubleTapGesture.NumberOfTapsRequired = 2;
                //doubleTapGesture.ShouldRecognizeSimultaneously += ShouldRecognizeSimultaneouslySingle;
                //doubleTapGesture.ShouldBeRequiredToFailBy += ShouldRecognizeSimultaneouslyDouble;

                singleTapGesture.RequireGestureRecognizerToFail(doubleTapGesture);
                this.AddGestureRecognizer(singleTapGesture);
                this.AddGestureRecognizer(doubleTapGesture);
            }

            // set scalefactor.
            _scaleFactor = this.ContentScaleFactor;

            // create the cache renderer.
            _cacheRenderer = new MapRenderer <CGContextWrapper> (
                new CGContextRenderer(_scaleFactor));
            _cachedScene           = new Scene2DSimple();
            _cachedScene.BackColor = SimpleColor.FromKnownColor(KnownColor.White).Value;
        }
Example #7
0
 /// <summary>
 /// Registers the animator.
 /// </summary>
 /// <param name="mapViewAnimator">Map view animator.</param>
 void IMapView.RegisterAnimator(MapViewAnimator mapViewAnimator)
 {
     _mapViewAnimator = mapViewAnimator;
 }
Example #8
0
 /// <summary>
 /// Registers the animator.
 /// </summary>
 /// <param name="mapViewAnimator">Map view animator.</param>
 void IMapView.RegisterAnimator(MapViewAnimator mapViewAnimator)
 {
     (_mapView as IMapViewSurface).RegisterAnimator(mapViewAnimator);
 }