/// <summary> /// Mouse handler that sets the coordinates of the clicked point into text in the toolbar. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Map_MouseClick(object sender, client.Map.MouseEventArgs e) { try { if (_mapWidget != null) { _mapWidget.Map.MouseClick -= Map_MouseClick; } // Find the map layer in the map widget that contains the data source. IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { if (_mapWidget != null && d.IsSelectable == true) { // Get the feature layer in the map for the data source. client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); //Clear Selection on Feature Layers in map featureL.ClearSelection(); } } location = e.MapPoint; if (_graphicsLayer == null) { _graphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer(); _graphicsLayer.ID = "BombThreatGraphics"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayer); } } _graphicsLayer.ClearGraphics(); Graphic graphic = new ESRI.ArcGIS.Client.Graphic(); graphic.Geometry = location; graphic.Attributes.Add("Evac", bombType.Text); ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); graphic.Symbol = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol; _graphicsLayer.MapTip = new ContentControl() { ContentTemplate = (DataTemplate)Resources["kymaptip"] }; _graphicsLayer.MapTip.SetBinding(ContentControl.ContentProperty, new Binding()); graphic.SetZIndex(1); _graphicsLayer.Graphics.Add(graphic); if (location != null) { RunButton.IsEnabled = true; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Error in mouseclick: " + ex.Message); } }
// *********************************************************************************** // * ... Select facilities that intersect the affeced area on the map // *********************************************************************************** private async void selectFeaturesOnTheMap(ESRI.ArcGIS.Client.Geometry.Polygon geometry) { // Find the Selectable data sources provided by feature layers in the map widget. var dataSourcesFromSameWidget = OperationsDashboard.Instance.DataSources.Select((dataSource) => { client.FeatureLayer fl = _mapWidget.FindFeatureLayer(dataSource); return(((fl != null) && (dataSource.IsSelectable)) ? fl : null); }); IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); if (dataSourcesFromSameWidget.Contains(featureL)) { ESRI.ArcGIS.OperationsDashboard.Query query = new ESRI.ArcGIS.OperationsDashboard.Query(); query.SpatialFilter = geometry; query.ReturnGeometry = true; query.Fields = new string[] { d.ObjectIdFieldName }; ESRI.ArcGIS.OperationsDashboard.QueryResult result = await d.ExecuteQueryAsync(query); if (result.Features.Count > 0) { // Get the array of IDs from the query results. var resultOids = from feature in result.Features select System.Convert.ToInt32(feature.Attributes[d.ObjectIdFieldName]); // For each result feature, find the corresponding graphic in the map. foreach (client.Graphic feature in featureL.Graphics) { int featureOid; int.TryParse(feature.Attributes[d.ObjectIdFieldName].ToString(), out featureOid); if (resultOids.Contains(featureOid)) { feature.Select(); } } } else if (d.IsSelectable == true) { featureL.ClearSelection(); } } } }
// *********************************************************************************** // * ...Clear the graphicslayers and charts // *********************************************************************************** private void clearMapToolParameters() { //clear the graphicsLayer _spillLocationGraphicsLayer.Graphics.Clear(); _ergZoneGraphicsLayer.Graphics.Clear(); _facilitiesGraphicsLayer.Graphics.Clear(); //Select features using polygon IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); featureL.ClearSelection(); } }
private void HighlightFeature_Click(object sender, RoutedEventArgs e) { SiteDetails sd = ((Button)sender).DataContext as SiteDetails; Geometry g = Geometry.FromJson(sd.ZoomExtent); ESRI.ArcGIS.Client.FeatureLayer fl = mapWidget.FindFeatureLayer(dataSource); for (int i = 0; i < fl.Graphics.Count; i++) { client.Graphic feature = fl.Graphics[i]; int featureOid; int.TryParse(feature.Attributes[dataSource.ObjectIdFieldName].ToString(), out featureOid); if (sd.f == featureOid.ToString()) { fl.ClearSelection(); feature.Select(); } } }
private void clearMapToolParameters() { ////clear the graphicsLayer _bufferPointLayer.Graphics.Clear(); _bufferPolygonLayer.Graphics.Clear(); if (_bufferParams != null) { _bufferParams.Features.Clear(); } ////Clear selected features IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); featureL.ClearSelection(); } _mapWidget.Map.MouseClick -= Map_MouseClick; }
private void DoneButton_Click(object sender, RoutedEventArgs e) { try { if (_graphicsLayer != null) { _graphicsLayer.Graphics.Clear(); } // Find the map layer in the map widget that contains the data source. IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { if (_mapWidget != null && d.IsSelectable == true) { // Get the feature layer in the map for the data source. client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); //Clear Selection on Feature Layers in map featureL.ClearSelection(); } } location = null; RunButton.IsEnabled = false; txtAddress.Text = "Enter Address"; if (_mapWidget != null) { _mapWidget.Map.MouseClick -= Map_MouseClick; _mapWidget.SetToolbar(null); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
private void RunButton_Click_1(object sender, RoutedEventArgs e) { try { if (_graphicsLayer != null) { _graphicsLayer.Graphics.Clear(); } // Find the map layer in the map widget that contains the data source. IEnumerable <ESRI.ArcGIS.OperationsDashboard.DataSource> dataSources = OperationsDashboard.Instance.DataSources; foreach (ESRI.ArcGIS.OperationsDashboard.DataSource d in dataSources) { if (_mapWidget != null && d.IsSelectable == true) { // Get the feature layer in the map for the data source. client.FeatureLayer featureL = _mapWidget.FindFeatureLayer(d); //Clear Selection on Feature Layers in map featureL.ClearSelection(); } } if (txtAddress.Text == "Enter Address") { int BuildingEvacDistance = 0; int OutdoorEvacDistance = 0; if (bombType.Text == "Pipe bomb") { BuildingEvacDistance = 70; OutdoorEvacDistance = 1200; } else if (bombType.Text == "Suicide vest") { BuildingEvacDistance = 110; OutdoorEvacDistance = 1750; } else if (bombType.Text == "Briefcase/suitcase bomb") { BuildingEvacDistance = 150; OutdoorEvacDistance = 1850; } else if (bombType.Text == "Sedan") { BuildingEvacDistance = 320; OutdoorEvacDistance = 1900; } else if (bombType.Text == "SUV/van") { BuildingEvacDistance = 400; OutdoorEvacDistance = 2400; } else if (bombType.Text == "Small delivery truck") { BuildingEvacDistance = 640; OutdoorEvacDistance = 3800; } else if (bombType.Text == "Container/water truck") { BuildingEvacDistance = 860; OutdoorEvacDistance = 5100; } else if (bombType.Text == "Semi-trailer") { BuildingEvacDistance = 1570; OutdoorEvacDistance = 9300; } if (BuildingEvacDistance == 0 || OutdoorEvacDistance == 0) { return; } //e.MapPoint.SpatialReference = _mapWidget.Map.SpatialReference; //location = e.MapPoint; if (location == null) { return; } Graphic graphic = new ESRI.ArcGIS.Client.Graphic(); graphic.Geometry = location; GeometryService geometryTask = new GeometryService(); geometryTask.Url = _serviceURL; geometryTask.BufferCompleted += GeometryService_BufferCompleted; geometryTask.Failed += GeometryService_Failed; // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering BufferParameters bufferParams = new BufferParameters() { Unit = LinearUnit.SurveyFoot, BufferSpatialReference = new SpatialReference(102004), OutSpatialReference = _mapWidget.Map.SpatialReference }; bufferParams.Features.Add(graphic); double[] theDistances = new double[] { BuildingEvacDistance, OutdoorEvacDistance }; bufferParams.Distances.AddRange(theDistances); geometryTask.BufferAsync(bufferParams); } else { findAddress(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error in run: " + ex.Message); } }