findTask.ExecuteCompleted += OnExecuteCompleted;
private void OnExecuteCompleted(object sender, FindEventArgs e) { Geometry zoomGeometry; foreach (var result in e.FindResults) { if (zoomGeometry == null) { zoomGeometry = result.Feature.Geometry.Extent; continue; } zoomGeometry = zoomGeometry.Extent.Union(result.Feature.Geometry.Extent); } YourMap.Extent = zoomGeometry; }
// If an item has been selected GraphicsLayer AgraphicsLayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; // graphicsLayer.ClearGraphics(); if (featureSet != null && featureSet.Features.Count > 0) { // Show selected feature attributes in DataGrid foreach (Graphic selectedFeature in featureSet.Features) { // Hightlight selected feature selectedFeature.Symbol = LayoutRoot.Resources["ResultsMarkerSymbol"] as SimpleMarkerSymbol; AgraphicsLayer.Graphics.Insert(0, 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)); Map.ZoomTo(displayExtent); Map.ZoomTo(new Envelope(displayExtent.XMin + 1.45, displayExtent.YMin + 1.45, displayExtent.XMax - 1.45, displayExtent.YMax - 1.45)); } ResultsDisplay.IsExpanded = true; } MyDrawSurface.IsEnabled = false;
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.