Beispiel #1
0
        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()));
                }
            }
        }