public void moveMapToRegion(ICameraPerspective cameraPerspective) { if (cameraPerspective == null || this.mapFunctions == null) { return; } this.mapFunctions.updateMapPerspective(cameraPerspective); }
public void updateMapPerspective(ICameraPerspective cameraPerspective) { if (nMap == null) { return; } if (cameraPerspective is CenterAndZoomCameraPerspective centerAndZoom) { var camera = CameraUpdateFactory.NewLatLngZoom(centerAndZoom.position.toNativeLatLng(), centerAndZoom.zoomLevel); if (centerAndZoom.isAnimated) { nMap.AnimateCamera(camera); } else { nMap.MoveCamera(camera); } } else if (cameraPerspective is CoordinatesAndPaddingCameraPerspective span) { var density = Resources.DisplayMetrics.Density; var list = span.positions.Select((Position p) => new LatLng(p.latitude, p.longitude)); var builder = new LatLngBounds.Builder(); builder.Includes(list.ToList()); var camera = nMap.GetCameraForLatLngBounds( builder.Build(), new int[] { (int)(span.padding.Left * density), (int)(span.padding.Top * density), (int)(span.padding.Right * density), (int)(span.padding.Bottom * density) }); if (span.isAnimated) { nMap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(camera)); } else { nMap.MoveCamera(CameraUpdateFactory.NewCameraPosition(camera)); } } else if (cameraPerspective is CoordinateCameraPerspective center) { if (center.isAnimated) { nMap.AnimateCamera(CameraUpdateFactory.NewLatLng(center.position.toNativeLatLng())); } else { nMap.MoveCamera(CameraUpdateFactory.NewLatLng(center.position.toNativeLatLng())); } } }
public void updateMapPerspective(ICameraPerspective cameraPerspective) { if (nMap == null) return; if (cameraPerspective is CenterAndZoomCameraPerspective centerAndZoom) { var coordinate = centerAndZoom.position.toNativeCLLocationCoordinate2D(); nMap.SetCenterCoordinate(coordinate, centerAndZoom.zoomLevel, centerAndZoom.isAnimated); } else if (cameraPerspective is CoordinatesAndPaddingCameraPerspective span) { var shapes = span.positions.Select((Position p) => new MGLPointFeature { Coordinate = new CLLocationCoordinate2D(p.latitude, p.longitude) }); var shapeCollecton = MGLShapeCollection.ShapeCollectionWithShapes(shapes.ToArray()); var camera = nMap.CameraThatFitsShape( shapeCollecton, 0, new UIEdgeInsets((System.nfloat)span.padding.Top, (System.nfloat)span.padding.Left, (System.nfloat)span.padding.Bottom, (System.nfloat)span.padding.Right)); nMap.SetCamera(camera, span.isAnimated); } else if(cameraPerspective is CoordinateCameraPerspective center){ nMap.SetCenterCoordinate(center.position.toNativeCLLocationCoordinate2D(), center.isAnimated); } }