/// <summary> /// Registers the animator. /// </summary> /// <param name="mapViewAnimator">Map view animator.</param> void IMapView.RegisterAnimator(MapViewAnimator mapViewAnimator) { (_mapView as IMapViewSurface).RegisterAnimator(mapViewAnimator); }
/// <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) { // register the default listener. (this as IInvalidatableMapSurface).RegisterListener(new DefaultTrigger(this)); // enable all interactions by default. this.MapAllowPan = true; this.MapAllowTilt = true; this.MapAllowZoom = true; // 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; _map.MapChanged += MapChanged; _doubleTapAnimator = new MapViewAnimator(this); this.BackgroundColor = UIColor.White; this.UserInteractionEnabled = true; 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 = (float)this.ContentScaleFactor; // create the cache renderer. _cacheRenderer = new MapRenderer<CGContextWrapper>( new CGContextRenderer(_scaleFactor)); _backgroundColor = SimpleColor.FromKnownColor(KnownColor.White).Value; }
/// <summary> /// Registers the animator. /// </summary> /// <param name="mapViewAnimator">Map view animator.</param> void IMapView.RegisterAnimator(MapViewAnimator mapViewAnimator) { _mapViewAnimator = mapViewAnimator; }
/// <summary> /// Registers the animator. /// </summary> /// <param name="mapViewAnimator">Map view animator.</param> public void RegisterAnimator(MapViewAnimator mapViewAnimator) { _mapViewAnimator = mapViewAnimator; }
/// <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; } }
/// <summary> /// Registers the animator. /// </summary> /// <param name="mapViewAnimator">Map view animator.</param> internal void RegisterAnimator(MapViewAnimator mapViewAnimator) { _mapViewAnimator = mapViewAnimator; }