ZoomToSelectedAsync keeps zooming in

12-23-2021 08:08 AM
Occasional Contributor II

I have a data grid holding point features and a row event handler to zoom to the feature when row is clicked. Each time a row is clicked, the map zooms to the feature but keeps zooming in. I want to have the map always zoom to 1:1,000. Each time the row is clicked, it zooms in at a ratio of  0.56. 1,000 -> 563 -> 316 -> 178... 


private async void ZoomToSelection(long objid)
	var mapView = MapView.Active;
	if (mapView == null) return;
	await QueuedTask.Run(() =>
		FeatureLayer pLayer = MapView.Active.Map.Layers.First(layer => layer.Name.Equals(Properties.Resources.permitsName)) as FeatureLayer;
		List<long> longs = new List<long> { objid };

		MapView.Active.Map.SetSelection(new Dictionary<MapMember, List<long>> { { pLayer, longs } });



I tried getting the camera and setting the scale and then zooming to the new camera but the map never zooms  after the first click. On subsequent clicks, nothing happens.


Camera camera = new Camera();
camera = mapView.Camera;
camera.Scale = 1000;                




If I put the camera code before I call the zoom async. I get an acceptable result. I set the scale at 1:1,785 to get close to the 1,000.



ArcPro 2.9


0 Replies