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); } }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.