private void ZoomToGraphic() { if (activeGraphic != null && activeGraphic.Geometry != null) { var graphicExtent = activeGraphic.Geometry.Extent; var mapExtent = MyMap.Extent; double mapExtentWidth = mapExtent.XMax - mapExtent.XMin; double mapExtentHeight = mapExtent.YMax - mapExtent.YMin; if (MyMap.Rotation != 0) { mapExtentHeight = mapExtent.XMax - mapExtent.XMin; mapExtentWidth = mapExtent.YMax - mapExtent.YMin; } //Just Center the map to your graphic MyMap.PanTo(graphicExtent.GetCenter()); //Zoom using factor. double xRatio = mapExtentWidth / graphicExtent.Width; double yRatio = mapExtentHeight /graphicExtent.Height; MyMap.Zoom(xRatio > yRatio ? yRatio : xRatio); } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.