private void Route_Complete(object sender, CalculateRouteCompletedEventArgs args) { myDrawObject.IsEnabled = true; routeResultsGraphicsLayer.ClearGraphics(); waypointGraphicsLayer.ClearGraphics(); StringBuilder directions = new StringBuilder(); ObservableCollection <RouteLeg> routeLegs = args.Result.Result.Legs; int numLegs = routeLegs.Count; int instructionCount = 0; for (int n = 0; n < numLegs; n++) { if ((n % 2) == 0) { AddStopPoint(mercator.FromGeographic(new MapPoint(routeLegs[n].ActualStart.Longitude, routeLegs[n].ActualStart.Latitude)) as MapPoint); AddStopPoint(mercator.FromGeographic(new MapPoint(routeLegs[n].ActualEnd.Longitude, routeLegs[n].ActualEnd.Latitude)) as MapPoint); } else if (n == (numLegs - 1)) { AddStopPoint(mercator.FromGeographic(new MapPoint(routeLegs[n].ActualEnd.Longitude, routeLegs[n].ActualEnd.Latitude)) as MapPoint); } directions.Append(string.Format("--Leg #{0}--\n", n + 1)); foreach (ItineraryItem item in routeLegs[n].Itinerary) { instructionCount++; directions.Append(string.Format("{0}. {1}\n", instructionCount, item.Text)); } } Regex regex = new Regex("<[/a-zA-Z:]*>", RegexOptions.IgnoreCase | RegexOptions.Multiline); DirectionsContentTextBlock.Text = regex.Replace(directions.ToString(), string.Empty); DirectionsGrid.Visibility = Visibility.Visible; RoutePath routePath = args.Result.Result.RoutePath; Polyline line = new Polyline(); line.Paths.Add(new PointCollection()); foreach (ESRI.ArcGIS.Client.Bing.RouteService.Location location in routePath.Points) { line.Paths[0].Add(mercator.FromGeographic(new MapPoint(location.Longitude, location.Latitude)) as MapPoint); } Graphic graphic = new Graphic() { Geometry = line, Symbol = LayoutRoot.Resources["RoutePathSymbol"] as Symbol }; routeResultsGraphicsLayer.Graphics.Add(graphic); }
private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e) { MyDrawObject.IsEnabled = false; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); Graphic graphic = new Graphic() { Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol, Geometry = e.Geometry as MapPoint }; graphicsLayer.Graphics.Add(graphic); Geoprocessor geoprocessorTask = new Geoprocessor("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/" + "Specialty/ESRI_Currents_World/GPServer/MessageInABottle"); geoprocessorTask.ExecuteCompleted += GeoprocessorTask_ExecuteCompleted; geoprocessorTask.Failed += GeoprocessorTask_Failed; List <GPParameter> parameters = new List <GPParameter>(); parameters.Add(new GPFeatureRecordSetLayer("Input_Point", e.Geometry as MapPoint)); parameters.Add(new GPDouble("Days", Convert.ToDouble(DaysTextBox.Text))); geoprocessorTask.ExecuteAsync(parameters); }
private void ClearGraphicsMenuItem_Click(object sender, EventArgs e) { MyDrawObject.DrawMode = DrawMode.None; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); }
void GeometryService_GeneralizeCompleted(object sender, GraphicsEventArgs e) { GraphicsLayer generalizedGraphicsLayer = MyMap.Layers["GeneralizedLineGraphicsLayer"] as GraphicsLayer; generalizedGraphicsLayer.ClearGraphics(); foreach (Graphic g in e.Results) { g.Symbol = LayoutRoot.Resources["NewLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; generalizedGraphicsLayer.Graphics.Add(g); ESRI.ArcGIS.Client.Geometry.Polyline p = g.Geometry as ESRI.ArcGIS.Client.Geometry.Polyline; foreach (ESRI.ArcGIS.Client.Geometry.PointCollection pc in p.Paths) { foreach (MapPoint point in pc) { Graphic vertice = new Graphic() { Symbol = LayoutRoot.Resources["NewMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol, Geometry = point }; generalizedGraphicsLayer.Graphics.Add(vertice); } } } generalizedGraphicsLayer.Opacity = 0.75; SliderStackPanel.Visibility = Visibility.Visible; GeneralizeButton.IsEnabled = true; }
private void FindDetails_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Highlight the graphic feature associated with the selected row DataGrid dataGrid = sender as DataGrid; int selectedIndex = dataGrid.SelectedIndex; if (selectedIndex > -1) { FindResult findResult = (FindResult)FindDetailsDataGrid.SelectedItem; Graphic graphic = findResult.Feature; switch (graphic.Attributes["Shape"].ToString()) { case "Polygon": graphic.Symbol = LayoutRoot.Resources["DefaultFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; case "Polyline": graphic.Symbol = LayoutRoot.Resources["DefaultLineSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; case "Point": graphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; break; } GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); graphicsLayer.Graphics.Add(graphic); } }
private void QueryPoint_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.MapPoint; ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters() { Geometry = clickPoint, MapExtent = MyMap.Extent, Width = (int)MyMap.ActualWidth, Height = (int)MyMap.ActualHeight, LayerOption = LayerOption.visible, SpatialReference = MyMap.SpatialReference }; //IdentifyTask identifyTask = new IdentifyTask("http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Average_Household_Size/MapServer/"); IdentifyTask identifyTask = new IdentifyTask(arcgisLayer.Url); identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted; identifyTask.Failed += IdentifyTask_Failed; identifyTask.ExecuteAsync(identifyParams); GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = clickPoint, Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphicsLayer.Graphics.Add(graphic); }
private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e) { ESRI.ArcGIS.Client.Geometry.MapPoint clickPoint = e.Geometry as MapPoint; ESRI.ArcGIS.Client.Tasks.IdentifyParameters identifyParams = new IdentifyParameters() { SpatialReference = MyMap.SpatialReference, Geometry = clickPoint, MapExtent = MyMap.Extent, Width = (int)MyMap.ActualWidth, Height = (int)MyMap.ActualHeight, LayerOption = LayerOption.visible }; IdentifyTask identifyTask = new IdentifyTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"); identifyTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted; identifyTask.Failed += IdentifyTask_Failed; identifyTask.ExecuteAsync(identifyParams); GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = clickPoint, Symbol = LayoutRoot.Resources["DefaultPictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphicsLayer.Graphics.Add(graphic); }
private void ExecuteButton_Click(object sender, RoutedEventArgs e) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); FindTask findTask = new FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer"); findTask.Failed += FindTask_Failed; FindParameters findParameters = new FindParameters(); // Layer ids to search findParameters.LayerIds.AddRange(new int[] { 0, 1, 2 }); // Fields in layers to search findParameters.SearchFields.AddRange(new string[] { "CITY_NAME", "NAME", "SYSTEM", "STATE_ABBR", "STATE_NAME" }); // Return features in map's spatial reference findParameters.SpatialReference = MyMap.SpatialReference; // Bind data grid to find results. Bind to the LastResult property which returns a list // of FindResult instances. When LastResult is updated, the ItemsSource property on the // will update. Binding resultFeaturesBinding = new Binding("LastResult"); resultFeaturesBinding.Source = findTask; FindDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding); findParameters.SearchText = FindText.Text; findTask.ExecuteAsync(findParameters); // Since binding to DataGrid, handling the ExecuteComplete event is not necessary. }
void myDrawObject_DrawComplete(object sender, DrawEventArgs e) { myDrawObject.IsEnabled = false; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.Geometry, Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); GeometryService geometryService = new GeometryService("http://serverapps101.esri.com/arcgis/rest/services/Geometry/GeometryServer"); geometryService.BufferCompleted += GeometryService_BufferCompleted; geometryService.Failed += GeometryService_Failed; BufferParameters bufferParams = new BufferParameters() { Unit = LinearUnit.StatuteMile, OutSpatialReference = MyMap.SpatialReference, Geodesic = true }; bufferParams.Features.Add(graphic); bufferParams.Distances.Add(5); geometryService.BufferAsync(bufferParams); }
private void MyDrawSurface_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args) { GraphicsLayer selectionGraphicslayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; selectionGraphicslayer.ClearGraphics(); QueryTask queryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"); queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted; queryTask.Failed += QueryTask_Failed; // Bind data grid to query results Binding resultFeaturesBinding = new Binding("LastResult.Features"); resultFeaturesBinding.Source = queryTask; QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding); Query query = new ESRI.ArcGIS.Client.Tasks.Query(); // Specify fields to return from query query.OutFields.AddRange(new string[] { "STATE_NAME", "SUB_REGION", "STATE_FIPS", "STATE_ABBR", "POP2000", "POP2007" }); query.Geometry = args.Geometry; // Return geometry with result features query.ReturnGeometry = true; query.OutSpatialReference = MyMap.SpatialReference; queryTask.ExecuteAsync(query); }
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); e.MapPoint.SpatialReference = MyMap.SpatialReference; Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = e.MapPoint, Symbol = LayoutRoot.Resources["DefaultClickSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.BufferCompleted += GeometryService_BufferCompleted; geometryService.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.StatuteMile, BufferSpatialReference = new SpatialReference(4326), OutSpatialReference = MyMap.SpatialReference }; bufferParams.Features.Add(graphic); bufferParams.Distances.Add(5); geometryService.BufferAsync(bufferParams); }
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { _geometryService.CancelAsync(); _queryTask.CancelAsync(); Graphic clickGraphic = new Graphic(); clickGraphic.Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; clickGraphic.Geometry = e.MapPoint; // Input spatial reference for buffer operation defined by first feature of input geometry array clickGraphic.Geometry.SpatialReference = MyMap.SpatialReference; _pointAndBufferGraphicsLayer.ClearGraphics(); _resultsGraphicsLayer.ClearGraphics(); clickGraphic.SetZIndex(2); _pointAndBufferGraphicsLayer.Graphics.Add(clickGraphic); // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters() { BufferSpatialReference = new SpatialReference(4326), OutSpatialReference = MyMap.SpatialReference, Unit = LinearUnit.Meter, }; bufferParams.Distances.Add(100); bufferParams.Features.Add(clickGraphic); _geometryService.BufferAsync(bufferParams); }
private void StopEdit(bool suppressEvent) { if (vertexLayer != null) { vertexLayer.ClearGraphics(); MyMap.Layers.Remove(vertexLayer); vertexLayer.MouseLeftButtonDown -= GraphicsLayer_MouseLeftButtonDown; vertexLayer = null; } StopTracking(); if (activeGraphic != null && activeGraphic.Geometry is Envelope) //if Envelope correct min/max { Envelope env = activeGraphic.Geometry as Envelope; double x1 = env.XMin; double x2 = env.XMax; double y1 = env.YMin; double y2 = env.YMax; env.XMin = Math.Min(x1, x2); env.XMax = Math.Max(x1, x2); env.YMin = Math.Min(y1, y2); env.YMax = Math.Max(y1, y2); } if (!suppressEvent && activeGraphic != null) { OnGeometryEdit(activeGraphic, null, null, Action.EditCompleted); } activeGraphic = null; }
private void esriTools_ToolbarItemClicked(object sender, ESRI.ArcGIS.Client.Toolkit.SelectedToolbarItemArgs e) { switch (e.Index) { case 0: // Point MyDrawSurface.DrawMode = DrawMode.Point; break; case 1: // Polyline MyDrawSurface.DrawMode = DrawMode.Polyline; break; case 2: // Polygon MyDrawSurface.DrawMode = DrawMode.Polygon; break; case 3: // Rectangle MyDrawSurface.DrawMode = DrawMode.Rectangle; break; default: // Clear MyDrawSurface.DrawMode = DrawMode.None; GraphicsLayer selectionGraphicslayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; selectionGraphicslayer.ClearGraphics(); QueryDetailsDataGrid.ItemsSource = null; ResultsDisplay.Visibility = Visibility.Collapsed; break; } MyDrawSurface.IsEnabled = (MyDrawSurface.DrawMode != DrawMode.None); StatusTextBlock.Text = e.Item.Text; }
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { _geoprocessorTask.CancelAsync(); GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); MapPoint mapPoint = e.MapPoint; mapPoint.SpatialReference = new SpatialReference(4326); Graphic graphic = new Graphic() { Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol, Geometry = mapPoint }; graphicsLayer.Graphics.Add(graphic); MyMap.Cursor = System.Windows.Input.Cursors.Wait; List <GPParameter> parameters = new List <GPParameter>(); parameters.Add(new GPFeatureRecordSetLayer("Input_Observation_Point", mapPoint)); parameters.Add(new GPLinearUnit("Viewshed_Distance", esriUnits.esriMiles, Convert.ToDouble(MilesTextBox.Text))); _geoprocessorTask.OutputSpatialReference = new SpatialReference(4326); _geoprocessorTask.ExecuteAsync(parameters); }
private void SelectionTool_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; string tagstring = (string)button.Tag; switch (tagstring) { case "0": // Point _drawSurface.DrawMode = DrawMode.Point; break; case "1": // Polyline _drawSurface.DrawMode = DrawMode.Polyline; break; case "2": // Polygon _drawSurface.DrawMode = DrawMode.Polygon; break; case "3": // Rectangle _drawSurface.DrawMode = DrawMode.Rectangle; break; default: // Clear _drawSurface.DrawMode = DrawMode.None; GraphicsLayer selectionGraphicslayer = Map.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; selectionGraphicslayer.ClearGraphics(); QueryDetailsDataGrid.ItemsSource = null; ResultsDisplay.IsExpanded = false; break; } _drawSurface.IsEnabled = (_drawSurface.DrawMode != DrawMode.None); }
private void QueryTask_ExecuteCompleted(object sender, QueryEventArgs args) { if (args.FeatureSet == null) { return; } FeatureSet featureSet = args.FeatureSet; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); if (featureSet != null && featureSet.Features.Count > 0) { foreach (Graphic feature in featureSet.Features) { ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = feature.Geometry, Symbol = LayoutRoot.Resources["ParcelFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol }; graphicsLayer.Graphics.Add(graphic); } } graphicsLayer.Graphics.Add(_unsimplifiedGraphic); }
private void MyMap_MouseClick(object sender, ESRI.ArcGIS.Client.Map.MouseEventArgs e) { _geoprocessorTask.CancelAsync(); GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); Graphic graphic = new Graphic() { Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol, Geometry = e.MapPoint, }; graphic.Attributes.Add("Info", "Start location"); string latlon = String.Format("{0}, {1}", e.MapPoint.X, e.MapPoint.Y); graphic.Attributes.Add("LatLon", latlon); graphic.SetZIndex(1); graphicsLayer.Graphics.Add(graphic); List <GPParameter> parameters = new List <GPParameter>(); parameters.Add(new GPFeatureRecordSetLayer("Input_Location", e.MapPoint)); parameters.Add(new GPString("Drive_Times", "1 2 3")); _geoprocessorTask.ExecuteAsync(parameters); }
private void MyDrawObject_DrawBegin(object sender, EventArgs args) { if (graphicsLayer.Graphics.Count >= 2) { graphicsLayer.ClearGraphics(); } }
private void UseLinq(Stream s) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); XDocument doc = XDocument.Load(s); XNamespace geo = "http://www.w3.org/2003/01/geo/wgs84_pos#"; var rssGraphics = from rssgraphic in doc.Descendants("item") select new RssGraphic { Geometry = new MapPoint( Convert.ToDouble(rssgraphic.Element(geo + "long").Value, System.Globalization.CultureInfo.InvariantCulture), Convert.ToDouble(rssgraphic.Element(geo + "lat").Value, System.Globalization.CultureInfo.InvariantCulture), new SpatialReference(4326)), Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol, RssAttributes = new Dictionary <string, object>() { { "MAGNITUDE", rssgraphic.Element("title").Value } } }; foreach (RssGraphic rssGraphic in rssGraphics) { foreach (KeyValuePair <string, object> rssAttribute in rssGraphic.RssAttributes) { rssGraphic.Attributes.Add(rssAttribute.Key, rssAttribute.Value); } graphicsLayer.Graphics.Add((Graphic)rssGraphic); } }
private void ClearGraphicsMenuItem_Click(object sender, EventArgs e) { MyDrawObject.DrawMode = DrawMode.None; GraphicsLayer graphicsLayer = MyMap.Layers["MySelectionGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); DataListBox.ItemsSource = null; }
public void ClearFlags() { if (_flagsGraphicsLayer == null) { throw new NullReferenceException("Map not already created"); } _flagsGraphicsLayer.ClearGraphics(); }
private void ResetButton_Click(object sender, RoutedEventArgs e) { GraphicsLayer outputGraphicsLayer = MyMap.Layers["OutputGraphicsLayer"] as GraphicsLayer; outputGraphicsLayer.ClearGraphics(); ResetButton.IsEnabled = false; }
void GeometryService_IntersectCompleted(object sender, GraphicsEventArgs e) { intersectGraphicsLayer.ClearGraphics(); foreach (Graphic g in e.Results) { SimpleFillSymbol symbol = new SimpleFillSymbol() { Fill = new System.Windows.Media.SolidColorBrush( System.Windows.Media.Color.FromArgb(255, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))), BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black), BorderThickness = 1 }; g.Symbol = symbol; intersectGraphicsLayer.Graphics.Add(g); } }
private void MyDrawObject_DrawBegin(object sender, EventArgs args) { GraphicsLayer graphicsLayerPolygon = MyMap.Layers["PolygonGraphicsLayer"] as GraphicsLayer; graphicsLayerPolygon.ClearGraphics(); GraphicsLayer graphicsLayerVertices = MyMap.Layers["VerticesGraphicsLayer"] as GraphicsLayer; graphicsLayerVertices.ClearGraphics(); }
private void MyToolbar_ToolbarItemClicked(object sender, ESRI.ArcGIS.Client.Toolkit.SelectedToolbarItemArgs e) { switch (e.Index) { case 0: // Point MyDrawObject.DrawMode = DrawMode.Point; _activeSymbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol; break; case 1: // Polyline MyDrawObject.DrawMode = DrawMode.Polyline; _activeSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as Symbol; break; case 2: // Polygon MyDrawObject.DrawMode = DrawMode.Polygon; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 3: // Rectangle MyDrawObject.DrawMode = DrawMode.Rectangle; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 4: // Freehand MyDrawObject.DrawMode = DrawMode.Freehand; _activeSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as Symbol; break; case 5: // Arrow MyDrawObject.DrawMode = DrawMode.Arrow; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 6: // Triangle MyDrawObject.DrawMode = DrawMode.Triangle; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 7: // Circle MyDrawObject.DrawMode = DrawMode.Circle; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 8: // Ellipse MyDrawObject.DrawMode = DrawMode.Ellipse; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; default: // Clear Graphics MyDrawObject.DrawMode = DrawMode.None; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); break; } MyDrawObject.IsEnabled = (MyDrawObject.DrawMode != DrawMode.None); }
private void ClearButton_Click(object sender, EventArgs e) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); _polyline = null; ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = false; // clear ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false; // show graph }
public void Refresh() { GraphicsLayer markerLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (markerLayer != null) { markerLayer.ClearGraphics(); RenderShape(this.fileName); } }
public void Refresh() { GraphicsLayer markerLayer = myMap.Layers[layerId.ToString()] as GraphicsLayer; if (markerLayer != null) { markerLayer.ClearGraphics(); RenderMarker(this.size, this.markerColor, this.style); } }
private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs e) { MyDrawObject.IsEnabled = false; try { if (Convert.ToDouble(MilesTextBox.Text) > 10) { MessageBox.Show("Distance must be 10 miles or less."); return; } } catch { MessageBox.Show("Distance must be a double."); return; } graphicsLayer.ClearGraphics(); MapPoint mapPoint = e.Geometry as MapPoint; mapPoint.SpatialReference = new SpatialReference(102100); Graphic graphic = new Graphic() { Symbol = LayoutRoot.Resources["StartMarkerSymbol"] as Symbol, Geometry = mapPoint }; graphicsLayer.Graphics.Add(graphic); List <GPParameter> parameters = new List <GPParameter>(); parameters.Add(new GPFeatureRecordSetLayer("Input_Features", mapPoint)); parameters.Add(new GPString("Height", HeightTextBox.Text)); parameters.Add(new GPLinearUnit("Distance", esriUnits.esriMiles, Convert.ToDouble(MilesTextBox.Text))); _geoprocessorTask.OutputSpatialReference = new SpatialReference(102100); WaitGrid.Visibility = Visibility.Visible; _geoprocessorTask.SubmitJobAsync(parameters); }
void GeometryService_DifferenceCompleted(object sender, GraphicsEventArgs e) { outputGraphicsLayer = MyMap.Layers["OutputGraphicsLayer"] as GraphicsLayer; outputGraphicsLayer.ClearGraphics(); foreach (Graphic g in e.Results) { if (g.Geometry is Polygon) g.Symbol = LayoutRoot.Resources["DifferenceFillSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; outputGraphicsLayer.Graphics.Add(g); } MyDrawObject.IsEnabled = true; ResetButton.IsEnabled = true; }
/// <summary> /// Create the waypoints for the route /// </summary> /// <param name="graphicLayerName"></param> /// <returns></returns> public bool CreateRouting(string graphicLayerName) { try { //Step 1 - Set points pointsSelected.Clear(); graphicsRouteLayer = gisOperations.GetFeatureLayer(graphicLayerName); graphicsRouteLayer.ClearGraphics(); // Handle points gisOperations.SetCompleteDrawEvent(DrawComplete); gisOperations.SetDrawModeContinuous(DrawMode.Point); return true; } catch (Exception ex) { messageBoxCustom.Show(String.Format("CreateRouting /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); return false; } }