//ZoomToPoint centerAndZoom(MyMap, (MapPoint)selectedFeature.Geometry, 100);
//Zoom to Point instead of Polygon for QueryTask_ExecuteCompleted private void centerAndZoom(ESRI.ArcGIS.Client.Map map, ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint, double resolution) { double ratio = 1.0; if (map.Resolution != 0.0) ratio = resolution / map.Resolution; if (ratio == 1.0) map.PanTo(mapPoint); else { ESRI.ArcGIS.Client.Geometry.MapPoint mapCenter = map.Extent.GetCenter(); double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio); double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio); map.ZoomToResolution(resolution, new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y)); } }
// Highlight selected feature selectedFeature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(selectedFeature);
// Zoom to selected feature (define expand percentage) ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent; double expandPercentage = 30; double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100); double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100); ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( selectedFeatureExtent.XMin - (widthExpand / 2), selectedFeatureExtent.YMin - (heightExpand / 2), selectedFeatureExtent.XMax + (widthExpand / 2), selectedFeatureExtent.YMax + (heightExpand / 2)); MyMap.ZoomTo(displayExtent);
private void centerAndZoom(ESRI.ArcGIS.Client.Map map, ESRI.ArcGIS.Client.Geometry.MapPoint mapPoint, double resolution) { double ratio = 1.0; if (map.Resolution != 0.0) ratio = resolution / map.Resolution; if (ratio == 1.0) map.PanTo(mapPoint); else { ESRI.ArcGIS.Client.Geometry.MapPoint mapCenter = map.Extent.GetCenter(); double X = (mapPoint.X - ratio * mapCenter.X) / (1 - ratio); double Y = (mapPoint.Y - ratio * mapCenter.Y) / (1 - ratio); map.ZoomToResolution(resolution, new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y)); } }
centerAndZoom(MyMap,selectedFeature,1200); error : cannot convert mapPoint
centerAndZoom(MyMap,selectedFeature.Geometry as MapPoint,1200)
// Highlight selected feature selectedFeature.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphicsLayer.Graphics.Add(selectedFeature); // Zoom to selected feature (define expand percentage) ESRI.ArcGIS.Client.Geometry.Envelope selectedFeatureExtent = selectedFeature.Geometry.Extent; // double expandPercentage = 30; //double widthExpand = selectedFeatureExtent.Width * (expandPercentage / 100); //double heightExpand = selectedFeatureExtent.Height * (expandPercentage / 100); //ESRI.ArcGIS.Client.Geometry.Envelope displayExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( //selectedFeatureExtent.XMin - (widthExpand / 2), //selectedFeatureExtent.YMin - (heightExpand / 2), //selectedFeatureExtent.XMax + (widthExpand / 2), //selectedFeatureExtent.YMax + (heightExpand / 2)); //MyMap.ZoomTo(displayExtent); centerAndZoom(MyMap,selectedFeature,2.0);
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.