private void setupGraphicsLayers() { try { _acLayers = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; _bufferPolygonLayer = new client.GraphicsLayer() { ID = "bufferPolygonLayer" }; _bufferPointLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "bufferPointLayer" }; if (_acLayers.Count() > 0) { _acLayers.ChildLayers.Add(_bufferPolygonLayer); _acLayers.ChildLayers.Add(_bufferPointLayer); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return; } }
/// <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 { client.Geometry.MapPoint clickPoint = e.MapPoint; WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); client.Geometry.MapPoint pt = null; pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint; if (_graphicsLayer == null) { _graphicsLayer = new client.GraphicsLayer(); _graphicsLayer.ID = "ComputedPoints"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayer); } } ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/AirCraftRouteGenerationLineAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); client.Graphic graphic = new client.Graphic(); graphic.Geometry = pt; graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol; _graphicsLayer.Graphics.Add(graphic); RunButton.IsEnabled = true; } catch (Exception ex) { MessageBox.Show("Error in map mouseclick: " + ex.Message); } }
/// <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) { client.Geometry.MapPoint clickPoint = e.MapPoint; //WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); ///client.Geometry.MapPoint pt = null; //pt = mercator.ToGeographic(clickPoint) as client.Geometry.MapPoint; if (_graphicsLayer == null) { _graphicsLayer = new client.GraphicsLayer(); _graphicsLayer.ID = "AircraftCommunicationGraphics"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayer); } } ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); client.Graphic graphic = new client.Graphic(); //graphic.Geometry = pt; graphic.Geometry = clickPoint; graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol; _graphicsLayer.Graphics.Add(graphic); if (_graphicsLayer != null && _graphicsLayerPoly != null) { if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0) { RunButton.IsEnabled = true; } } }
/// <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 { client.Geometry.MapPoint clickPoint = e.MapPoint; if (_graphicsLayer == null) { _graphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer(); _graphicsLayer.ID = "FarthestOnCircleGraphics"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayer); } } ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/FarthestOnCircleAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); client.Graphic graphic = new client.Graphic(); graphic.Geometry = clickPoint; graphic.Symbol = mydictionary["RedPin"] as client.Symbols.MarkerSymbol; _graphicsLayer.Graphics.Add(graphic); RunButton.IsEnabled = true; if (_mapWidget != null) { _mapWidget.Map.MouseClick -= Map_MouseClick; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
private void gpSateEphemeris_JobCompleted(object sender, JobInfoEventArgs e) { try { if (_graphicsLayerPoly == null) { _graphicsLayerPoly = new client.GraphicsLayer(); _graphicsLayerPoly.ID = "SensorFootprints"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayerPoly); } } else { _graphicsLayerPoly.Graphics.Clear(); } if (_graphicsLayerLine == null) { _graphicsLayerLine = new client.GraphicsLayer(); _graphicsLayerLine.ID = "EphemerisLines"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayerLine); } } else { _graphicsLayerLine.Graphics.Clear(); } if (_graphicsLayerPoint == null) { _graphicsLayerPoint = new client.GraphicsLayer(); _graphicsLayerPoint.ID = "EphemerisPoints"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayerPoint); } } else { _graphicsLayerPoint.Graphics.Clear(); } ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/SatelliteEphemerisGenerationAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); gp = sender as Geoprocessor; _jobid = e.JobInfo.JobId; gp.GetResultDataAsync(e.JobInfo.JobId, "SensorFootprints", "Footprints"); gp.GetResultDataCompleted += gp_GetResultDataCompleted; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
/// <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); } }
// *********************************************************************************** // * add graphicslayers to the AcceleratedDisplayLayers group layer // *********************************************************************************** private void setupGraphicsLayers() { try { client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; _ergZoneGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "ergZoneGraphicsLayer" }; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_ergZoneGraphicsLayer); } _spillLocationGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "spillLocationGraphicsLayer" }; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_spillLocationGraphicsLayer); } _facilitiesGraphicsLayer = new ESRI.ArcGIS.Client.GraphicsLayer() { ID = "facilitiesGraphicsLayer" }; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_facilitiesGraphicsLayer); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return; } }
void targetAreaDraw_DrawComplete(object sender, client.DrawEventArgs e) { try { if (_graphicsLayerPoly == null) { _graphicsLayerPoly = new client.GraphicsLayer(); _graphicsLayerPoly.ID = "AircraftCommunicationGraphicsPoly"; client.AcceleratedDisplayLayers aclyrs = _mapWidget.Map.Layers.FirstOrDefault(lyr => lyr is client.AcceleratedDisplayLayers) as client.AcceleratedDisplayLayers; if (aclyrs.Count() > 0) { aclyrs.ChildLayers.Add(_graphicsLayerPoly); } } ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/AircraftCommunicationCoverageAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); WebMercator mercator = new ESRI.ArcGIS.Client.Projection.WebMercator(); client.Graphic g = new client.Graphic(); //g.Geometry = mercator.ToGeographic(e.Geometry) as client.Geometry.Polygon; //g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol; g.Geometry = e.Geometry as client.Geometry.Polygon; g.Symbol = mydictionary["BasicFillSymbol_Yellow_Trans_6"] as client.Symbols.SimpleFillSymbol; _graphicsLayerPoly.Graphics.Add(g); targetAreaDraw.DrawMode = client.DrawMode.None; if (_graphicsLayer != null && _graphicsLayerPoly != null) { if (_graphicsLayer.Graphics.Count() > 0 && _graphicsLayerPoly.Graphics.Count() > 0) { RunButton.IsEnabled = true; } } targetAreaDraw.IsEnabled = false; } catch (Exception ex) { MessageBox.Show("Error in draw complete: " + ex.Message); } }
void locatorTask_AddressToLocationsCompleted(object sender, AddressToLocationsEventArgs e) { try { List <AddressCandidate> returnedCandidates = e.Results; 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; } if (e.Results.Count > 0) { AddressCandidate candidate = returnedCandidates[0]; ResourceDictionary mydictionary = new ResourceDictionary(); mydictionary.Source = new Uri("/BombThreatAddin;component/SymbolDictionary.xaml", UriKind.RelativeOrAbsolute); Graphic graphic = new ESRI.ArcGIS.Client.Graphic(); graphic.Geometry = candidate.Location; graphic.Symbol = mydictionary["DefaultClickSymbol"] as client.Symbols.MarkerSymbol; location = candidate.Location; graphic.SetZIndex(1); 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.Graphics.Add(graphic); GeometryService geometryTask = new GeometryService(); geometryTask.Url = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"; 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 { MessageBox.Show("No address found. Example schema: 380 New York Ave., Redlands, CA or click on the map"); } } catch (Exception ex) { MessageBox.Show("Error in Address location complete: " + ex.Message); } }