var layout = LayoutView.Active.Layout; var mf = layout.GetElementsAsFlattenedList().OfType<MapFrame>() .First(mf => mf.Name == mapFrame); var autoCamera = mf.GetAutoCamera(); autoCamera.Source = AutoCameraSource.Fixed; autoCamera.AutoCameraType = AutoCameraType.Center; var camera = mf.GetMapView(LayoutView.Active).Camera; var center = mf.GetViewCenter(); //var extent = EnvelopeBuilderEx.CreateEnvelope( // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); //autoCamera.Extent = extent; var camera2 = new CIMViewCamera() { Heading = 0, Pitch = -90, Roll = 0, Scale = 21169571, X = 855708, Y = 1112409, Z = double.NaN }; autoCamera.Camera = camera2; var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); autoCamera.IntersectLayerPath = states.URI; if (mf.ValidateAutoCamera(autoCamera) && !mf.IsMapSeriesMapFrame()) mf.SetAutoCamera(autoCamera);
var layout = LayoutView.Active.Layout; var mf = layout.GetElementsAsFlattenedList().OfType<MapFrame>() .First(mf => mf.Name == mapFrame); var autoCamera = mf.GetAutoCamera(); autoCamera.Source = AutoCameraSource.Fixed; autoCamera.AutoCameraType = AutoCameraType.CenterAndScale; var camera = mf.GetMapView(LayoutView.Active).Camera; var center = mf.GetViewCenter(); //var extent = EnvelopeBuilderEx.CreateEnvelope( // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); //autoCamera.Extent = extent; var camera2 = new CIMViewCamera() { Heading = 0, Pitch = -90, Roll = 0, Scale = 21169571, X = 1310669.0 + ((400748.5 - 1310669.0) / 2.0), Y = 800296.4 + ((1424520.74 - 800296.4) / 2.0), Z = double.NaN }; autoCamera.Camera = camera2; var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); //autoCamera.IntersectLayerPath = states.URI; if (mf.ValidateAutoCamera(autoCamera) && !mf.IsMapSeriesMapFrame()) mf.SetAutoCamera(autoCamera);
var layout = LayoutView.Active.Layout; var mf = layout.GetElementsAsFlattenedList().OfType<MapFrame>() .First(mf => mf.Name == mapFrame); var autoCamera = mf.GetAutoCamera(); autoCamera.Source = AutoCameraSource.Fixed; autoCamera.AutoCameraType = AutoCameraType.Scale; var camera = mf.GetMapView(LayoutView.Active).Camera; var center = mf.GetViewCenter(); //var extent = EnvelopeBuilderEx.CreateEnvelope( // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); //autoCamera.Extent = extent; var camera2 = new CIMViewCamera() { Heading = 0, Pitch = -90, Roll = 0, Scale = 20000571, X = 1310669.0 + ((400748.5 - 1310669.0) / 2.0), Y = 800296.4 + ((1424520.74 - 800296.4) / 2.0), Z = double.NaN }; autoCamera.Camera = camera2; var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); //autoCamera.IntersectLayerPath = states.URI; if (mf.ValidateAutoCamera(autoCamera) && !mf.IsMapSeriesMapFrame()) mf.SetAutoCamera(autoCamera);
public Task<bool> RotateView(double heading) { //Get the active map view. var mapView = MapView.Active; if (mapView == null) return Task.FromResult(false); //Get the camera for the view, adjust the heading and zoom to the new camera position. var camera = mapView.Camera; camera.Heading = heading; return mapView.ZoomToAsync(camera, TimeSpan.Zero); } // or use the synchronous method public Task<bool> RotateViewAsync(double heading) { return QueuedTask.Run(() => { //Get the active map view. var mapView = MapView.Active; if (mapView == null) return false; //Get the camera for the view, adjust the heading and zoom to the new camera position. var camera = mapView.Camera; camera.Heading = heading; return mapView.ZoomTo(camera, TimeSpan.Zero); }); }
Target Platforms: Windows 11, Windows 10