public BufferPoint() { InitializeComponent(); mapView1.Map.InitialExtent = new Envelope(-10863035.970, 3838021.340, -10744801.344, 3887145.299); InitializePictureMarkerSymbol().ContinueWith((_) => { }, TaskScheduler.FromCurrentSynchronizationContext()); sms = LayoutRoot.Resources["MySimpleMarkerSymbol"] as SimpleMarkerSymbol; sfs = LayoutRoot.Resources["MySimpleFillSymbol"] as SimpleFillSymbol; graphicsLayer = mapView1.Map.Layers["MyGraphicsLayer"] as GraphicsLayer; mapView1.MapViewTapped += mapView1_MapViewTapped; }
// Create four point graphics on the map in the center of four equal quadrants private void MyMapView_NavigationCompleted(object sender, EventArgs e) { MyMapView.NavigationCompleted -= MyMapView_NavigationCompleted; try { var height = MyMapView.Extent.Height / 4; var width = MyMapView.Extent.Width / 4; var center = MyMapView.Extent.GetCenter(); var topLeft = new MapPoint(center.X - width, center.Y + height, MyMapView.SpatialReference); var topRight = new MapPoint(center.X + width, center.Y + height, MyMapView.SpatialReference); var bottomLeft = new MapPoint(center.X - width, center.Y - height, MyMapView.SpatialReference); var bottomRight = new MapPoint(center.X + width, center.Y - height, MyMapView.SpatialReference); var symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Diamond }; _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = topLeft, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = topRight, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = bottomLeft, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = bottomRight, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = new MapPoint(0, 0), Symbol = new SimpleMarkerSymbol() { Size = 15, Color = Colors.Blue } }); } catch (Exception ex) { var _x = new MessageDialog("Error occurred : " + ex.Message, "Sample Error").ShowAsync(); } }
private void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateImagery()); // Create initial map location and reuse the location for graphic MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500); // Set initial viewpoint myMap.InitialViewpoint = initialViewpoint; // Provide used Map to the MapView _myMapView.Map = myMap; // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); // Add created overlay to the MapView _myMapView.GraphicsOverlays.Add(overlay); // Create a simple marker symbol SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol() { Color = Color.Red, Size = 10, Style = SimpleMarkerSymbolStyle.Circle }; // Add a new graphic with a central point that was created earlier Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol); overlay.Graphics.Add(graphicWithSymbol); }
private void AddSampleGraphic(GraphicsLayer gLyr) { SimpleMarkerSymbol sampleSymbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Colors.Red), Size = 12, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle }; Graphic g = new Graphic() { Geometry = new MapPoint(-110, 35), Symbol = sampleSymbol }; g.Attributes.Add("Attribute1", "Value1"); g.Attributes.Add("Attribute2", "Value2"); g.Attributes.Add("Attribute3", "Value3"); g.Attributes.Add("Attribute4", "Value4"); g.Attributes.Add("Attribute5", "Value5"); g.Attributes.Add("Attribute6", "Value6"); g.Attributes.Add("Attribute7", "Value7"); g.Attributes.Add("Attribute8", "Value8"); g.Attributes.Add("Attribute9", "Value9"); g.Attributes.Add("Attribute10", "Value10"); gLyr.Graphics.Add(g); }
private void MapView_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (nameof(MapView.SpatialReference).Equals(e.PropertyName) && null != MapView.SpatialReference) { Task.Run(() => { // Load the data var inputFile = new FileInfo(Settings.Default.GeonamesFilePath); var delimiter = Settings.Default.Delimiter; switch (delimiter) { case @"\t": delimiter = "\t"; break; } var clusterFile = new ClusterPointTextFile(inputFile, delimiter, Settings.Default.XTokenIndex, Settings.Default.YTokenIndex, Settings.Default.StartRowIndex); var distanceCalculator = new EuclideanDistanceCalculator(); var clusterer = new KMeansClusterer(distanceCalculator); return clusterer.CreateClusters(clusterFile, Settings.Default.ClusterCount); }).ContinueWith((clusterTask)=> { // Create the graphics var clusters = clusterTask.Result; var random = new Random(); var wgs84 = SpatialReference.Create(4326); foreach (var cluster in clusters) { // Create a graphic layer var layer = new GraphicsLayer(); layer.RenderingMode = GraphicsRenderingMode.Static; foreach (var element in cluster.Elements) { var clusterPoint = element as ClusterPoint; if (null != clusterPoint) { var mapPoint = new MapPoint(clusterPoint.X, clusterPoint.Y, wgs84); var projectedMapPoint = GeometryEngine.Project(mapPoint, MapView.SpatialReference); var graphic = new Graphic(projectedMapPoint); layer.Graphics.Add(graphic); } } // Create a marker symbol var markerSymbol = new SimpleMarkerSymbol(); markerSymbol.Style = SimpleMarkerStyle.Circle; markerSymbol.Size = 6; markerSymbol.Color = Color.FromRgb((byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255)); // Create a renderer var renderer = new SimpleRenderer(); renderer.Symbol = markerSymbol; layer.Renderer = renderer; MapView.Map.Layers.Add(layer); } }, TaskScheduler.FromCurrentSynchronizationContext()); } }
private void OnViewpointChanged(object sender, EventArgs e) { // Unhook the event MyMapView.ViewpointChanged -= OnViewpointChanged; // Get area that is shown in a MapView Polygon visibleArea = MyMapView.VisibleArea; // Get extent of that area Envelope extent = visibleArea.Extent; // Get central point of the extent MapPoint centerPoint = extent.GetCenter(); // Create values inside the visible extent for creating graphic var extentWidth = extent.Width / 5; var extentHeight = extent.Height / 10; // Create point collection PointCollection points = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y - extentHeight * 2), new MapPoint(centerPoint.X - extentWidth * 2, centerPoint.Y + extentHeight * 2), new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y + extentHeight * 2), new MapPoint(centerPoint.X + extentWidth * 2, centerPoint.Y - extentHeight * 2) }; // Create overlay to where graphics are shown GraphicsOverlay overlay = new GraphicsOverlay(); // Add points to the graphics overlay foreach (var point in points) { // Create new graphic and add it to the overlay overlay.Graphics.Add(new Graphic(point)); } // Create symbol for points SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol() { Color = Colors.Yellow, Size = 30, Style = SimpleMarkerSymbolStyle.Square, }; // Create simple renderer with symbol SimpleRenderer renderer = new SimpleRenderer(pointSymbol); // Set renderer to graphics overlay overlay.Renderer = renderer; // Add created overlay to the MapView MyMapView.GraphicsOverlays.Add(overlay); }
public static SimpleMarkerSymbol CreatePointSymbol() { Color symbolColor = (Color)ColorConverter.ConvertFromString("#FF9900"); SimpleMarkerSymbol _symbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(symbolColor), Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle, Size = 13 }; return _symbol; }
public BufferPoint() { InitializeComponent(); MyMapView.Map.InitialViewpoint = new Viewpoint(new Envelope(-10863035.970, 3838021.340, -10744801.344, 3887145.299)); InitializePictureMarkerSymbol(); sms = LayoutRoot.Resources["MySimpleMarkerSymbol"] as SimpleMarkerSymbol; sfs = LayoutRoot.Resources["MySimpleFillSymbol"] as SimpleFillSymbol; graphicsLayer = MyMapView.Map.Layers["MyGraphicsLayer"] as GraphicsLayer; MyMapView.MapViewTapped += mapView1_MapViewTapped; }
/// <summary>Construct Nearest Coordinate sample control</summary> public NearestCoordinateInGeometry() { InitializeComponent(); _vertexSymbol = new SimpleMarkerSymbol() { Color = Colors.LightGreen, Size = 8, Style = SimpleMarkerStyle.Circle }; _userPointSymbol = new SimpleMarkerSymbol() { Color = Colors.Black, Size = 10, Style = SimpleMarkerStyle.Circle }; _graphicsOverlay = MyMapView.GraphicsOverlays["graphicsOverlay"]; _targetOverlay = MyMapView.GraphicsOverlays["targetOverlay"]; _coordinateOverlay = MyMapView.GraphicsOverlays["coordinateOverlay"]; MyMapView.NavigationCompleted += MyMapView_NavigationCompleted; }
/// <summary>Construct Nearest Coordinate sample control</summary> public NearestCoordinateInGeometry() { InitializeComponent(); _vertexSymbol = new SimpleMarkerSymbol() { Color = Colors.LightGreen, Size = 8, Style = SimpleMarkerStyle.Circle }; _userPointSymbol = new SimpleMarkerSymbol() { Color = Colors.Black, Size = 10, Style = SimpleMarkerStyle.Circle }; mapView.Map.InitialExtent = (Envelope)GeometryEngine.Project( new Envelope(-83.3188395774275, 42.61428312652851, -83.31295664068958, 42.61670913269855, SpatialReferences.Wgs84), SpatialReferences.WebMercator); mapView.ExtentChanged += mapView_ExtentChanged; }
/// <summary> /// Initializes a new instance of the ViewshedViewModel class. /// </summary> public ViewshedViewModel() { this.CreateViewshedRelayCommand = new RelayCommand(CreateViewshed); Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) => { this.mapView = mapView; this.sms = new SimpleMarkerSymbol(); this.sms.Color = System.Windows.Media.Colors.Black; sms.Style = SimpleMarkerStyle.X; sms.Size = 20; this.simpleRenderer = new SimpleRenderer(); this.simpleRenderer.Symbol = sms; this.simpleLineSymbol = new SimpleLineSymbol(); this.simpleLineSymbol.Color = System.Windows.Media.Colors.Red; this.simpleLineSymbol.Width = 2; this.simpleLineSymbol.Style = SimpleLineStyle.Solid; this.simpleFillSymbol = new SimpleFillSymbol(); this.simpleFillSymbol.Color = (Color)ColorConverter.ConvertFromString("#44FF9999"); this.simpleFillSymbol.Outline = simpleLineSymbol; this.viewshedRenderer = new SimpleRenderer(); this.viewshedRenderer.Symbol = this.simpleFillSymbol; gpTask = new Geoprocessor(new Uri(viewshedServiceUrl)); this.viewshedGraphicsLayer = new GraphicsLayer(); this.viewshedGraphicsLayer.ID = "Viewshed"; this.viewshedGraphicsLayer.DisplayName = "Viewshed"; this.viewshedGraphicsLayer.Renderer = this.viewshedRenderer; this.viewshedGraphicsLayer.InitializeAsync(); this.inputGraphicsLayer = new GraphicsLayer(); this.inputGraphicsLayer.ID = "Input Point"; this.inputGraphicsLayer.DisplayName = "Input Point"; this.inputGraphicsLayer.Renderer = this.simpleRenderer; this.inputGraphicsLayer.InitializeAsync(); this.mapView.Map.Layers.Add(this.inputGraphicsLayer); this.mapView.Map.Layers.Add(this.viewshedGraphicsLayer); }); }
public Generalize() { InitializeComponent(); MyMapView.NavigationCompleted += MyMapView_NavigationCompleted; originalGraphicsLayer = MyMapView.Map.Layers["OriginalLineGraphicsLayer"] as GraphicsLayer; generalizedGraphicsLayer = MyMapView.Map.Layers["GeneralizedLineGraphicsLayer"] as GraphicsLayer; defaultMarkerSymbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as SimpleMarkerSymbol; defaultLineSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as SimpleLineSymbol; generalizedLineSymbol = LayoutRoot.Resources["GeneralizedLineSymbol"] as SimpleLineSymbol; generalizedMarkerSymbol = LayoutRoot.Resources["GeneralizedMarkerSymbol"] as SimpleMarkerSymbol; }
/// <summary>Construct Generalize sample control</summary> public Generalize() { InitializeComponent(); MyMapView.NavigationCompleted += MyMapView_NavigationCompleted; _originalGraphicsOverlay = MyMapView.GraphicsOverlays["originalOverlay"]; _generalizedGraphicsOverlay = MyMapView.GraphicsOverlays["generalizedLineOverlay"]; _defaultMarkerSymbol = layoutGrid.Resources["DefaultMarkerSymbol"] as SimpleMarkerSymbol; _defaultLineSymbol = layoutGrid.Resources["DefaultLineSymbol"] as SimpleLineSymbol; _generalizedLineSymbol = layoutGrid.Resources["GeneralizedLineSymbol"] as SimpleLineSymbol; _generalizedMarkerSymbol = layoutGrid.Resources["GeneralizedMarkerSymbol"] as SimpleMarkerSymbol; }
//��˸�� public static void FlashPoint(IMapControlDefault mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleMarkerSymbol iMarkerSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iMarkerSymbol = new SimpleMarkerSymbol(); iMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; iRgbColor = new RgbColor(); iRgbColor.RGB = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb(); iMarkerSymbol.Color = iRgbColor; iSymbol = (ISymbol)iMarkerSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; mapControl.FlashShape(iGeometry, 5, 300, iSymbol); }
public Generalize() { InitializeComponent(); mapView1.Map.InitialExtent = new Envelope(-12000000, 3000000, -7000000, 7000000, SpatialReferences.WebMercator); originalGraphicsLayer = mapView1.Map.Layers["OriginalLineGraphicsLayer"] as GraphicsLayer; generalizedGraphicsLayer = mapView1.Map.Layers["GeneralizedLineGraphicsLayer"] as GraphicsLayer; mapView1.Loaded += mapView1_Loaded; defaultMarkerSymbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as SimpleMarkerSymbol; defaultLineSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as SimpleLineSymbol; generalizedLineSymbol = LayoutRoot.Resources["GeneralizedLineSymbol"] as SimpleLineSymbol; generalizedMarkerSymbol = LayoutRoot.Resources["GeneralizedMarkerSymbol"] as SimpleMarkerSymbol; }
private Graphic CreateGraphic(Esri.ArcGISRuntime.Geometry.Geometry geometry) { // Create a graphic to display the specified geometry Symbol symbol = null; switch (geometry.GeometryType) { // Symbolize with a fill symbol case GeometryType.Envelope: case GeometryType.Polygon: { symbol = new SimpleFillSymbol() { Color = Color.Red, Style = SimpleFillSymbolStyle.Solid, }; break; } // Symbolize with a line symbol case GeometryType.Polyline: { symbol = new SimpleLineSymbol() { Color = Color.Red, Style = SimpleLineSymbolStyle.Solid, Width = 5d }; break; } // Symbolize with a marker symbol case GeometryType.Point: case GeometryType.Multipoint: { symbol = new SimpleMarkerSymbol() { Color = Color.Red, Style = SimpleMarkerSymbolStyle.Circle, Size = 15d }; break; } } // pass back a new graphic with the appropriate symbol return(new Graphic(geometry, symbol)); }
private async void Initialize() { // Create the map. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Create a point in the Greenwich observatory courtyard in London, UK, the location of the prime meridian. _originalPoint = new MapPoint(538985.355, 177329.516, SpatialReference.Create(27700)); // Set the initial extent to an extent centered on the point. Viewpoint initialViewpoint = new Viewpoint(_originalPoint, 5000); myMap.InitialViewpoint = initialViewpoint; // Load the map and add the map to the map view. await myMap.LoadAsync(); MyMapView.Map = myMap; // Create a graphics overlay to hold the original and projected points. _pointsOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(_pointsOverlay); // Add the point as a graphic with a blue square. SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Colors.Blue, 15); Graphic originalGraphic = new Graphic(_originalPoint, markerSymbol); _pointsOverlay.Graphics.Add(originalGraphic); // Get the path to the projection engine data (if it exists). string peFolderPath = GetProjectionDataPath(); if (!string.IsNullOrEmpty(peFolderPath)) { TransformationCatalog.ProjectionEngineDirectory = peFolderPath; MessagesTextBox.Text = "Using projection data found at '" + peFolderPath + "'"; } else { MessagesTextBox.Text = "Projection engine data not found."; } // Show the input and output spatial reference. InSpatialRefTextBox.Text = "In WKID = " + _originalPoint.SpatialReference.Wkid; OutSpatialRefTextBox.Text = "Out WKID = " + myMap.SpatialReference.Wkid; // Create a list of transformations to fill the UI list box. GetSuitableTransformations(_originalPoint.SpatialReference, myMap.SpatialReference, UseExtentCheckBox.IsChecked == true); }
private void UpdateUIFromMapPoint(MapPoint selectedPoint) { try { // Check if the selected point can be formatted into coordinates. CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DecimalDegrees, 0); } catch (Exception e) { // Check if the excpetion is because the coordinates are out of range. if (e.Message == "Invalid argument: coordinates are out of range") { // Set all of the text fields to contain the error message. DecimalDegreesTextField.Text = "Coordinates are out of range"; DmsTextField.Text = "Coordinates are out of range"; UtmTextField.Text = "Coordinates are out of range"; UsngTextField.Text = "Coordinates are out of range"; // Clear the selectionss symbol. MyMapView.GraphicsOverlays[0].Graphics.Clear(); } return; } // Update the decimal degrees text DecimalDegreesTextField.Text = CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DecimalDegrees, 4); // Update the degrees, minutes, seconds text DmsTextField.Text = CoordinateFormatter.ToLatitudeLongitude(selectedPoint, LatitudeLongitudeFormat.DegreesMinutesSeconds, 1); // Update the UTM text UtmTextField.Text = CoordinateFormatter.ToUtm(selectedPoint, UtmConversionMode.NorthSouthIndicators, true); // Update the USNG text UsngTextField.Text = CoordinateFormatter.ToUsng(selectedPoint, 4, true); // Clear existing graphics overlays MyMapView.GraphicsOverlays[0].Graphics.Clear(); // Create a symbol to symbolize the point SimpleMarkerSymbol symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, Color.Yellow, 20); // Create the graphic Graphic symbolGraphic = new Graphic(selectedPoint, symbol); // Add the graphic to the graphics overlay MyMapView.GraphicsOverlays[0].Graphics.Add(symbolGraphic); }
private void TransformationsListBox_ItemSelected(object sender, SelectedItemChangedEventArgs e) { // Get the selected transform from the list box. Return if there isn't a selected item. DatumTransformationListBoxItem selectedListBoxItem = TransformationsListBox.SelectedItem as DatumTransformationListBoxItem; if (selectedListBoxItem == null) { return; } // Get the datum transformation object from the list box item. DatumTransformation selectedTransform = selectedListBoxItem.TransformationObject; try { // Project the original point using the selected transform. MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, MyMapView.SpatialReference, selectedTransform); // Update the projected graphic (if it already exists), create it otherwise. if (_projectedPointGraphic != null) { _projectedPointGraphic.Geometry = projectedPoint; } else { // Create a symbol to represent the projected point (a cross to ensure both markers are visible). SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Colors.Red, 15); // Create the point graphic and add it to the overlay. _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker); _pointsOverlay.Graphics.Add(_projectedPointGraphic); } MessagesTextBox.Text = "Projected point using transform: " + selectedTransform.Name; } catch (ArcGISRuntimeException ex) { // Exception if a transformation is missing grid files. MessagesTextBox.Text = "Error using selected transformation: " + ex.Message; // Remove the projected point graphic (if it exists). if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic)) { _pointsOverlay.Graphics.Remove(_projectedPointGraphic); _projectedPointGraphic = null; } } }
private void Initialize() { // Create a map with a topographic basemap and add it to the map view. _myMapView.Map = new Map(Basemap.CreateTopographic()); // Create a fill symbol for geodesic buffer polygons. Colors geodesicBufferColor = Colors.FromArgb(120, 255, 0, 0); SimpleLineSymbol geodesicOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, geodesicBufferColor, 2); SimpleFillSymbol geodesicBufferFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, geodesicBufferColor, geodesicOutlineSymbol); // Create a fill symbol for planar buffer polygons. Colors planarBufferColor = Colors.FromArgb(120, 0, 0, 255); SimpleLineSymbol planarOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, planarBufferColor, 2); SimpleFillSymbol planarBufferFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, planarBufferColor, planarOutlineSymbol); // Create a marker symbol for tap locations. SimpleMarkerSymbol tapSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.White, 14); // Create a graphics overlay to display geodesic polygons, set its renderer and add it to the map view. GraphicsOverlay geodesicPolysOverlay = new GraphicsOverlay { Id = "GeodesicPolys", Renderer = new SimpleRenderer(geodesicBufferFillSymbol) }; _myMapView.GraphicsOverlays.Add(geodesicPolysOverlay); // Create a graphics overlay to display planar polygons, set its renderer and add it to the map view. GraphicsOverlay planarPolysOverlay = new GraphicsOverlay { Id = "PlanarPolys", Renderer = new SimpleRenderer(planarBufferFillSymbol) }; _myMapView.GraphicsOverlays.Add(planarPolysOverlay); // Create a graphics overlay to display tap locations for buffers, set its renderer and add it to the map view. GraphicsOverlay tapLocationsOverlay = new GraphicsOverlay { Id = "TapPoints", Renderer = new SimpleRenderer(tapSymbol) }; _myMapView.GraphicsOverlays.Add(tapLocationsOverlay); // Show the colors for each type of buffer in the UI. ShowBufferSwatches(planarBufferColor, geodesicBufferColor); }
/// <summary> /// 设置点元素的样式 /// </summary> /// <param name="rgbColor">颜色</param> /// <param name="OutLineColor">轮廓颜色</param> private IElement createElement(IRgbColor rgbColor, IRgbColor OutLineColor) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); pSimpleMarkerSymbol.Color = rgbColor; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = OutLineColor; pSimpleMarkerSymbol.Size = 15; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement pMElement = new MarkerElement() as IMarkerElement; pMElement.Symbol = pSimpleMarkerSymbol; IElement ele = (IElement)pMElement; return(ele); }
public void AddShpLayer(string strVecName) { _shpFileHostLayer.AddData(strVecName, null); CodeCell.AgileMap.Core.IMap map = _shpFileHostLayer.Map as CodeCell.AgileMap.Core.IMap; CodeCell.AgileMap.Core.FeatureLayer fetL = map.LayerContainer.Layers[0] as CodeCell.AgileMap.Core.FeatureLayer; _curShpLayerName = fetL.Name; SimpleMarkerSymbol sym = new SimpleMarkerSymbol(masSimpleMarkerStyle.Circle); sym.Size = new System.Drawing.Size(4, 4); fetL.Renderer = new SimpleFeatureRenderer(sym); CodeCell.AgileMap.Core.FeatureClass fetc = fetL.Class as CodeCell.AgileMap.Core.FeatureClass; CodeCell.AgileMap.Core.Envelope evp = fetc.FullEnvelope.Clone() as CodeCell.AgileMap.Core.Envelope; GeoDo.RSS.Core.DrawEngine.CoordEnvelope cvEvp = new GeoDo.RSS.Core.DrawEngine.CoordEnvelope(evp.MinX, evp.MaxX, evp.MinY, evp.MaxY); this.canvasHost1.Canvas.CurrentEnvelope = cvEvp; this.canvasHost1.Canvas.Refresh(enumRefreshType.All); }
//简单渲染,点符号 public static void easy_point(string filename, IRgbColor point_rgb, int width) { //实例化ISimpleFillSysmbol变量, 提供简单的填充符号类型 ISimpleMarkerSymbol pSimplemarkerSymbol = new SimpleMarkerSymbol(); pSimplemarkerSymbol.Color = point_rgb; pSimplemarkerSymbol.OutlineSize = width; //实例化简单渲染变量 ISimpleRenderer pSimpleRender = new SimpleRenderer(); //设置pSimpleRender的符号样式 pSimpleRender.Symbol = pSimplemarkerSymbol as ISymbol; Render_tool(pSimpleRender, filename); }
private Graphic GenerateGraphic(double lat, double lon) { MapPoint point = new MapPoint(lon, lat, SpatialReferences.Wgs84); var graphic = new Graphic(point); var symbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Color = Colors.DarkGreen }; graphic.Symbol = symbol; return(graphic); }
/// <summary> /// 住所検索結果用のシンボル作成 /// </summary> private SimpleRenderer CreateGeocoordingSymbol() { SimpleMarkerSymbol resultGeocoordingSymbol = new SimpleMarkerSymbol() { Style = SimpleMarkerSymbolStyle.Circle, Size = 12, Color = Colors.Blue, }; SimpleRenderer resultRenderer = new SimpleRenderer() { Symbol = resultGeocoordingSymbol }; return(resultRenderer); }
private async void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { try { // Get the input map point (in the map's coordinate system, State Plane for North Central Texas). MapPoint tapMapPoint = e.Location; // Check if the point coordinates are within the spatial reference envelope. bool withinValidExent = GeometryEngine.Contains(_spatialReferenceArea, tapMapPoint); // If the input point is not within the valid extent for the spatial reference, warn the user and return. if (!withinValidExent) { MessageDialog dialog = new MessageDialog("Location is not valid to buffer using the defined spatial reference.", "Out of bounds"); await dialog.ShowAsync(); return; } // Get the buffer radius (in miles) from the text box. double bufferDistanceMiles = Convert.ToDouble(BufferDistanceMilesTextBox.Text); // Use a helper method to get the buffer distance in feet (unit that's used by the spatial reference). double bufferDistanceFeet = LinearUnits.Miles.ConvertTo(LinearUnits.Feet, bufferDistanceMiles); // Create a simple marker symbol (red circle) to display where the user tapped/clicked on the map. SimpleMarkerSymbol tapSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 10); // Create a new graphic to show the tap location. Graphic tapGraphic = new Graphic(tapMapPoint, tapSymbol) { // Specify a z-index value on the point graphic to make sure it draws on top of the buffer polygons. ZIndex = 2 }; // Store the specified buffer distance as an attribute with the graphic. tapGraphic.Attributes["distance"] = bufferDistanceFeet; // Add the tap point graphic to the buffer graphics overlay. MyMapView.GraphicsOverlays["buffers"].Graphics.Add(tapGraphic); } catch (Exception ex) { // Display an error message. await new MessageDialog(ex.Message, "Error creating buffer point").ShowAsync(); } }
private void Initialize() { // Create new map with basemap layer. Map myMap = new Map(Basemap.CreateImageryWithLabels()); // Create several map points using the WGS84 coordinates (latitude and longitude). MapPoint oldFaithfulPoint = new MapPoint(-110.828140, 44.460458, SpatialReferences.Wgs84); MapPoint cascadeGeyserPoint = new MapPoint(-110.829004, 44.462438, SpatialReferences.Wgs84); MapPoint plumeGeyserPoint = new MapPoint(-110.829381, 44.462735, SpatialReferences.Wgs84); // Use the two points farthest apart to create an envelope. Envelope initialEnvelope = new Envelope(oldFaithfulPoint, plumeGeyserPoint); // Set the map initial viewpoint. myMap.InitialViewpoint = new Viewpoint(initialEnvelope); // Add the map to the map view. _myMapView.Map = myMap; // Set the viewpoint to the envelope with padding. _myMapView.SetViewpointGeometryAsync(initialEnvelope, 50); // Create a graphics overlay. GraphicsOverlay myGraphicOverlay = new GraphicsOverlay(); // Create graphics based upon the map points. Graphic oldFaithfulGraphic = new Graphic(oldFaithfulPoint); Graphic cascadeGeyserGraphic = new Graphic(cascadeGeyserPoint); Graphic plumeGeyserGraphic = new Graphic(plumeGeyserPoint); // Add the graphics to the graphics overlay. myGraphicOverlay.Graphics.Add(oldFaithfulGraphic); myGraphicOverlay.Graphics.Add(cascadeGeyserGraphic); myGraphicOverlay.Graphics.Add(plumeGeyserGraphic); // Create a simple marker symbol - red, cross, size 12. SimpleMarkerSymbol mySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.Red, 12); // Create a simple renderer based on the simple marker symbol. SimpleRenderer myRenderer = new SimpleRenderer(mySymbol); // Apply the renderer to the graphics overlay (all graphics use the same symbol). myGraphicOverlay.Renderer = myRenderer; // Add the graphics overlay to the map view. _myMapView.GraphicsOverlays.Add(myGraphicOverlay); }
private async void Initialize() { StatusGrid.BackgroundColor = new Color(0, 0, 0, 0.5); try { BusyIndicator.IsVisible = true; Status.Text = "Loading Utility Network..."; // Setup Map with Feature Layer(s) that contain Utility Network. MyMapView.Map = new Map(Basemap.CreateStreetsNightVector()) { InitialViewpoint = _startingViewpoint }; // Add the layer with electric distribution lines. FeatureLayer lineLayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115")); lineLayer.Renderer = new SimpleRenderer(new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3)); MyMapView.Map.OperationalLayers.Add(lineLayer); // Add the layer with electric devices. FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100")); MyMapView.Map.OperationalLayers.Add(electricDevicelayer); // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), MyMapView.Map); Status.Text = "Click on the network lines or points to add a utility element."; // Create symbols for starting points and barriers. _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.Green, 20d); _barrierPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.Red, 20d); // Create a graphics overlay. GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(graphicsOverlay); } catch (Exception ex) { Status.Text = "Loading Utility Network failed..."; await Application.Current.MainPage.DisplayAlert(ex.Message.GetType().Name, ex.Message, "OK"); } finally { BusyIndicator.IsVisible = false; } }
private static void MapUsingProportionalSymbolRenderer() { ISimpleMarkerSymbol marker = new SimpleMarkerSymbol(); marker.Style = esriSimpleMarkerStyle.esriSMSCircle; ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor(); marker.Size = 10; marker.Color = markerColor; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; IMap map = mxDoc.FocusMap; string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); IFeatureLayer fLayer = layer as IFeatureLayer; IFeatureClass fClass = fLayer.FeatureClass as IFeatureClass; IFeatureCursor cursor = fClass.Search(null, true); IDataStatistics dataStats = new DataStatisticsClass(); dataStats.Cursor = cursor as ICursor; string fieldName = CboFields.GetSelectedField(); dataStats.Field = fieldName; IStatisticsResults statResult = dataStats.Statistics; IProportionalSymbolRenderer propSymRenderer = new ProportionalSymbolRendererClass(); propSymRenderer.Field = fieldName; propSymRenderer.MinDataValue = statResult.Minimum == 0.0 ? 1 : statResult.Minimum; propSymRenderer.MaxDataValue = statResult.Maximum; propSymRenderer.FlanneryCompensation = true; propSymRenderer.ValueUnit = esriUnits.esriUnknownUnits; propSymRenderer.MinSymbol = marker as ISymbol; propSymRenderer.LegendSymbolCount = 3; propSymRenderer.CreateLegendSymbols(); IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = propSymRenderer as IFeatureRenderer; mxDoc.ActiveView.Refresh(); mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, gFLayer , mxDoc.ActiveView.Extent); mxDoc.UpdateContents(); }
private void init() { operation = OperateType.None; pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.FromArgb(0, 0, 0), 8.0); lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 2.0); fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.FromArgb(125, 255, 0, 0), new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(0, 0, 0), 2.0)); vertexSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Square, Color.FromArgb(0, 0, 255), 8.0); curSelGraphic = null; orgPoint = null; selGracphicIndex = -1; selPointIndex = -1; listOfClipGraphics = new List <Graphic>(); // 画点 drawPoint.Checked += (sender, e) => { operation = OperateType.DrawPoint; }; // 画线 drawLine.Checked += (sender, e) => { operation = OperateType.DrawPolyline; if (pointCollection != null) { pointCollection.Clear(); } else { pointCollection = new Esri.ArcGISRuntime.Geometry.PointCollection(myMapView.Map.SpatialReference); } }; // 画面 drawPoly.Checked += (sender, e) => { operation = OperateType.DrawPolygon; if (pointCollection != null) { pointCollection.Clear(); } else { pointCollection = new Esri.ArcGISRuntime.Geometry.PointCollection(myMapView.Map.SpatialReference); } }; }
public void metro_data() { /* first get stops */ Task.Factory.StartNew(async() => { Uri u = new System.Uri("https://services1.arcgis.com/gOY38HDnFUYPDony/ArcGIS/rest/services/la_busstops1217/FeatureServer/1"); var agsl_stop = new ServiceFeatureTable(u); await agsl_stop.LoadAsync(); Application.Current.Dispatcher.Invoke( () => { var stopsLayer = new Esri.ArcGISRuntime.Mapping.FeatureLayer(agsl_stop); MySceneView.Scene.OperationalLayers.Add(stopsLayer); }); Debug.WriteLine("busstop: " + agsl_stop.LoadStatus); }); /* then get vehicles */ WebClient client = new WebClient(); var wgs84 = MySceneView.Scene.SpatialReference; metro = new GraphicsOverlay(); metro.SceneProperties.SurfacePlacement = SurfacePlacement.Draped; Task.Factory.StartNew(async() => { while (true) { string downloadString = client.DownloadString("http://api.metro.net/agencies/lametro/vehicles/"); dynamic res = JsonConvert.DeserializeObject(downloadString); metro.Graphics.Clear(); foreach (dynamic vehicle in res.items) { var ploc = new MapPoint(vehicle.longitude.Value, vehicle.latitude.Value, 0, wgs84); var pmark = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Colors.IndianRed, 8); var ptest = new Graphic(ploc, pmark); metro.Graphics.Add(ptest); } await Task.Delay(1000); } }); MySceneView.GraphicsOverlays.Add(metro); }
private Graphic point_graphic_creation(MapPoint point) { Graphic _polypointGraphic = null; //Create point symbol with outline // var pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10); // pointSymbol.Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 2); var pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Transparent, 10); pointSymbol.Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Transparent, 2); //Create point graphic with geometry & symbol _polypointGraphic = new Graphic(point, pointSymbol); //Add point graphic to graphic overlay //_sketchOverlay.Graphics.Add(_polypointGraphic); return(_polypointGraphic); }
public ExMap(MapView esriMapView) { _mapView = esriMapView; ArcGISTiledMapServiceLayer layer = new ArcGISTiledMapServiceLayer(); layer.ServiceUri = "http://server.arcgisonline.com/arcgis/rest/services/ESRI_StreetMap_World_2D/MapServer"; _myLocationLayer = new GraphicsLayer(); _redliningGraphicsLayer = new GraphicsLayer(); _mapView.Map.Layers.Add(layer); _mapView.Map.Layers.Add(_redliningGraphicsLayer); _mapView.Map.Layers.Add(_myLocationLayer); _mapView.ExtentChanged += _mapView_ExtentChanged; _mapView.NavigationCompleted += _mapView_NavigationCompleted; //////////Init DrawControl////////// //_drawControl = new DrawControl(_mapView); //_drawMode = GeoDrawMode.None; //_drawControl.SetDrawMode(DrawMode.None); //_drawControl.DrawCompletedEvent += _drawControl_DrawCompletedEvent; ///////Init default Draw Symbols//////// PointMarkerSymbol = new SimpleMarkerSymbol(); PointMarkerSymbol.Color = Colors.Red; PointMarkerSymbol.Size = 15; PointMarkerSymbol.Style = SimpleMarkerStyle.Circle; PolygonFillSymbol = new SimpleFillSymbol(); PolygonFillSymbol.Outline = new SimpleLineSymbol(); PolygonFillSymbol.Outline.Color = Colors.Red; PolygonFillSymbol.Outline.Width = 3; PolygonFillSymbol.Color = Color.FromArgb(100, 255, 0, 0); LineSymbol = new SimpleLineSymbol(); LineSymbol.Color = Colors.Red; LineSymbol.Width = 5; LineSymbol.Style = SimpleLineStyle.Solid; TextDrawsymbol = new TextSymbol(); TextDrawsymbol.Text = "Text"; TextDrawsymbol.Font = new SymbolFont("Arial", 15); }
private IElement PointElementRenderer(IGeometry geo, IRgbColor color) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = false; simpleMarkerSymbol.Size = 5; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement pMarkerElement = new MarkerElementClass(); pMarkerElement.Symbol = simpleMarkerSymbol; IElement pElement = pMarkerElement as IElement; pElement.Geometry = geo; return(pElement); }
//闪烁点 private void FlashPoint(AxMapControl mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleMarkerSymbol iMarkerSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iMarkerSymbol = new SimpleMarkerSymbol(); iMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; iRgbColor = new RgbColor(); iRgbColor.Blue = 255; iRgbColor.Green = 255; iMarkerSymbol.Color = iRgbColor; iSymbol = (ISymbol)iMarkerSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; mapControl.FlashShape(iGeometry, 3, 500, iSymbol); }
private void TransformationsPicker_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { // Get the selected transform from the spinner. Return if none is selected. TransformationsAdapter adapter = (TransformationsAdapter)_transformationsPicker.Adapter; DatumTransformation selectedTransform = adapter[e.Position]; if (selectedTransform == null) { return; } try { // Project the original point using the selected transform. MapPoint projectedPoint = (MapPoint)GeometryEngine.Project(_originalPoint, _myMapView.SpatialReference, selectedTransform); // Update the projected graphic (if it already exists), create it otherwise. if (_projectedPointGraphic != null) { _projectedPointGraphic.Geometry = projectedPoint; } else { // Create a symbol to represent the projected point (a cross to ensure both markers are visible). SimpleMarkerSymbol projectedPointMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.Red, 15); // Create the point graphic and add it to the overlay. _projectedPointGraphic = new Graphic(projectedPoint, projectedPointMarker); _pointsOverlay.Graphics.Add(_projectedPointGraphic); } _messagesTextView.Text = "Projected point using transform: " + selectedTransform.Name; } catch (ArcGISRuntimeException ex) { // Exception if a transformation is missing grid files. _messagesTextView.Text = "Error using selected transformation: " + ex.Message; // Remove the projected point graphic (if it exists). if (_projectedPointGraphic != null && _pointsOverlay.Graphics.Contains(_projectedPointGraphic)) { _pointsOverlay.Graphics.Remove(_projectedPointGraphic); _projectedPointGraphic = null; } } }
private async void Initialize() { // Show a map in the default WebMercator spatial reference. _myMapView.Map = new Map(Basemap.CreateNationalGeographic()); // Add a graphics overlay for showing the tapped point. GraphicsOverlay overlay = new GraphicsOverlay(); SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 5); overlay.Renderer = new SimpleRenderer(markerSymbol); _myMapView.GraphicsOverlays.Add(overlay); // Zoom to Minneapolis. Envelope startingEnvelope = new Envelope(-10995912.335747, 5267868.874421, -9880363.974046, 5960699.183877, SpatialReferences.WebMercator); await _myMapView.SetViewpointGeometryAsync(startingEnvelope); }
public DrawOptionsGroupVm() { var polylineSymbol = new SimpleLineSymbol { Color = Colors.Red, Width = 2 }; DrawPolyLine = new DrawOptionVm(DrawShape.Polyline, polylineSymbol); var contourSymbol = new SimpleLineSymbol { Color = Colors.Purple, Width = 2 }; DrawContour = new DrawOptionVm(DrawShape.Polyline, contourSymbol); DrawPolyLine.Attributes.Add(Diamond14Attributes.LineType, Diamond14Attributes.LineTypeLine); DrawContour.Attributes.Add(Diamond14Attributes.LineType, Diamond14Attributes.LineTypeContour); var polygonSymbol = new SimpleFillSymbol { Color = Color.FromArgb(0x66, 0xff, 0, 0) }; DrawPolygon = new DrawOptionVm(DrawShape.Polygon, polygonSymbol); var pointSymbol = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle }; DrawPoint = new DrawOptionVm(DrawShape.Point, pointSymbol); drawOptions.Add(DrawPoint); drawOptions.Add(DrawPolygon); drawOptions.Add(DrawPolyLine); drawOptions.Add(DrawContour); StartDrawCommand = new DelegateCommand(StartDraw); StartEditCommand = new DelegateCommand(StartEdit); DeleteGraphicCommand = new DelegateCommand(DeleteGraphic); UpdateValueCommand = new DelegateCommand(UpdateValue); //IsEnabledChangedCommand = new DelegateCommand<bool?>(IsEnabledChanged); //CompleteCommand = new DelegateCommand(Complete, CanComplete); //CancelCommand = new DelegateCommand(Cancel, CanCancel); }
private async void Initialize() { // Create new Map Map myMap = new Map(Basemap.CreateOceans()); // Create the hurricanes feature layer once FeatureLayer noOffsetLayer = new FeatureLayer(_featureLayerUri); // Apply a blue dot renderer to distinguish hurricanes without offsets SimpleMarkerSymbol blueDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10); noOffsetLayer.Renderer = new SimpleRenderer(blueDot); // Add the non-offset layer to the map myMap.OperationalLayers.Add(noOffsetLayer); // Create the offset hurricanes feature layer FeatureLayer withOffsetLayer = new FeatureLayer(_featureLayerUri); // Center the Viewpoint on the FeatureLayer once the feature layer has loaded. withOffsetLayer.Loaded += (s, e) => { _myMapView.SetViewpointGeometryAsync(withOffsetLayer.FullExtent, 50); }; // Apply a red dot renderer to distinguish these hurricanes from the non-offset hurricanes SimpleMarkerSymbol redDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10); withOffsetLayer.Renderer = new SimpleRenderer(redDot); // Apply the time offset (red hurricane dots will be from 10 days before the current extent) withOffsetLayer.TimeOffset = new TimeValue(10, Esri.ArcGISRuntime.ArcGISServices.TimeUnit.Days); // Add the layer to the map myMap.OperationalLayers.Add(withOffsetLayer); // Apply the Map to the MapView _myMapView.Map = myMap; // Ensure the no offset layer is loaded await noOffsetLayer.LoadAsync(); // Store a reference to the original time extent _originalExtent = noOffsetLayer.FullTimeExtent; // Update the time extent set on the map UpdateTimeExtent(); }
private async void Initialize() { try { _progressBar.Visibility = Android.Views.ViewStates.Visible; _status.Text = "Loading Utility Network..."; // Setup Map with Feature Layer(s) that contain Utility Network. _myMapView.Map = new Map(Basemap.CreateStreetsNightVector()) { InitialViewpoint = _startingViewpoint }; // Add the layer with electric distribution lines. FeatureLayer lineLayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115")); lineLayer.Renderer = new SimpleRenderer(new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3)); _myMapView.Map.OperationalLayers.Add(lineLayer); // Add the layer with electric devices. FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100")); _myMapView.Map.OperationalLayers.Add(electricDevicelayer); // Create and load the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), _myMapView.Map); _status.Text = "Click on the network lines or points to add a utility element."; // Create symbols for starting points and barriers. _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.Green, 20d); _barrierPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.Red, 20d); // Create a graphics overlay. GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); _myMapView.GraphicsOverlays.Add(graphicsOverlay); } catch (Exception ex) { _status.Text = "Loading Utility Network failed..."; CreateDialog(ex.Message); } finally { _progressBar.Visibility = Android.Views.ViewStates.Invisible; } }
public void FlashDstItem() { IMapControl3 mapControl = this.m_iApp.MapControl as IMapControl3; Color randColor = (new CRandomColor()).GetRandColor(); ISimpleLineSymbol simpleLineSymbolClass = new SimpleLineSymbol(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = ((int)randColor.R); rgbColorClass.Green = ((int)randColor.G); rgbColorClass.Blue = ((int)randColor.B); simpleLineSymbolClass.Color = (rgbColorClass); simpleLineSymbolClass.Width = (5); object obj = simpleLineSymbolClass; ISimpleMarkerSymbol simpleMarkerSymbolClass = new SimpleMarkerSymbol(); simpleMarkerSymbolClass.Color = (rgbColorClass); simpleMarkerSymbolClass.Size = (10); simpleMarkerSymbolClass.Style = (0); object obj1 = simpleMarkerSymbolClass; ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); simpleFillSymbolClass.Style = 0; simpleFillSymbolClass.Outline.Width = (6); simpleFillSymbolClass.Color = (rgbColorClass); object obj2 = simpleFillSymbolClass; try { if (this.igeometry_0.GeometryType == esriGeometryType.esriGeometryPoint) { mapControl.DrawShape(this.igeometry_0, ref obj1); } if (this.igeometry_0.GeometryType == esriGeometryType.esriGeometryPolyline) { mapControl.DrawShape(this.igeometry_0, ref obj); } if (this.igeometry_0.GeometryType == esriGeometryType.esriGeometryPolygon) { mapControl.DrawShape(this.igeometry_0, ref obj2); } } catch { } }
private void MyMapView_GeoViewTapped(object sender, GeoViewInputEventArgs e) { try { // Normalize the tapped point. var centralizedPoint = (MapPoint)GeometryEngine.NormalizeCentralMeridian(e.Location); // Add the map point to the list that will be used by the GeometryEngine.ConvexHull operation. _inputPointCollection.Add(centralizedPoint); // Check if there are at least three points. if (_inputPointCollection.Count > 2) { // Enable the button for creating hulls. _convexHullButton.Enabled = true; } // Create a simple marker symbol to display where the user tapped/clicked on the map. The marker symbol // will be a solid, red circle. SimpleMarkerSymbol userTappedSimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10); // Create a new graphic for the spot where the user clicked on the map using the simple marker symbol. Graphic userTappedGraphic = new Graphic(e.Location, new Dictionary <string, object>() { { "Type", "Point" } }, userTappedSimpleMarkerSymbol) { ZIndex = 0 }; // Set the Z index for the user tapped graphic so that it appears above the convex hull graphic(s) added later. userTappedGraphic.ZIndex = 1; // Add the user tapped/clicked map point graphic to the graphic overlay. _graphicsOverlay.Graphics.Add(userTappedGraphic); } catch (System.Exception ex) { // Display an error message if there is a problem adding user tapped graphics. AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Can't add user tapped graphic"); alertBuilder.SetMessage(ex.ToString()); alertBuilder.Show(); } }
public void setSelectedItem(object selectedItem) { GraphicsOverlay.Graphics.Clear(); FeatureAttributes = new List <FeatureAttribute>(); if (selectedItem is FeatureResult) { List <FeatureAttribute> _featureAttributes = new List <FeatureAttribute>(); var featureResult = ((FeatureResult)selectedItem); var layer = LayerList.FirstOrDefault(_layer => _layer.Name == featureResult.layer.Name); foreach (var keyValue in featureResult.feature.Attributes) { var name = keyValue.Key; if (layer != null) { if (layer is FeatureLayer) { var field = ((FeatureLayer)layer).FeatureTable.Fields.FirstOrDefault(_field => _field.Name == keyValue.Key); if (field != null) { name = field.Alias; } } } _featureAttributes.Add(new FeatureAttribute(name, keyValue.Value?.ToString())); } var geometry = featureResult.feature.Geometry; Symbol symbol; if (geometry.GeometryType == GeometryType.Point || geometry.GeometryType == GeometryType.Multipoint) { symbol = new SimpleMarkerSymbol(); } else if (geometry.GeometryType == GeometryType.Polyline) { symbol = new SimpleLineSymbol(); } else { symbol = new SimpleFillSymbol(); } GraphicsOverlay.Graphics.Add(new Graphic(geometry, symbol)); FeatureAttributes = _featureAttributes; } }
/// <summary> /// /// </summary> /// <returns></returns> public static ClassBreaksRenderer MakeDOCRenderer() { double symbolSize = 10; ClassBreaksRenderer breaksRenderer = new ClassBreaksRenderer(); breaksRenderer.Field = "Measurement"; SimpleMarkerSymbol defaultSymbol = new SimpleMarkerSymbol(); defaultSymbol.Size = symbolSize; defaultSymbol.Color = (SolidColorBrush)new BrushConverter().ConvertFromString("#f50404"); defaultSymbol.Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle; breaksRenderer.DefaultSymbol = defaultSymbol; List<double> min = new List<double> { 0,6,12,18,24,30,36,48,60 }; List<double> max = new List<double> { 6,12,18,24,30,36,48,60,1000 }; List<string> colors = new List<string> { "#fa5903","#fc8b00","#fcc304","#f5f502","#c7f704","#95f703","#5bf600","#02f502","#39a801" }; for (int i = 0; i < 9; i++) { ESRI.ArcGIS.Client.ClassBreakInfo classBreak = new ESRI.ArcGIS.Client.ClassBreakInfo(); SimpleMarkerSymbol breakSymbol = new SimpleMarkerSymbol(); breakSymbol.Size = symbolSize; breakSymbol.Color = (SolidColorBrush)new BrushConverter().ConvertFromString(colors[i]); breakSymbol.Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle; classBreak.Symbol = breakSymbol; classBreak.MinimumValue = min[i]; classBreak.MaximumValue = max[i]; breaksRenderer.Classes.Add(classBreak); } return breaksRenderer; }
/// <summary> /// 闪烁地物 /// </summary> /// <param name="pMapControl"></param> /// <param name="pGeometry"></param> public static void FlashGeometry(IMapControl4 pMapControl, IGeometry pGeometry) { ICartographicLineSymbol ipCartographicLineSymbol; ISimpleFillSymbol ipSimpleFillSymbol; ISimpleMarkerSymbol ipSimpleMarkersymbol; ISymbol ipSymbol = null; IRgbColor ipColor; int Size; ipColor = new RgbColor(); ipColor.Blue = 255; Size = 2; esriGeometryType type = pGeometry.GeometryType; if (type == esriGeometryType.esriGeometryPolyline) { ipCartographicLineSymbol = new CartographicLineSymbol(); ipSymbol = (ISymbol)ipCartographicLineSymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipCartographicLineSymbol.Width = Size; ipCartographicLineSymbol.Color = ipColor; ipCartographicLineSymbol.Cap = esriLineCapStyle.esriLCSRound; } else if (type == esriGeometryType.esriGeometryPolygon) { ipSimpleFillSymbol = new SimpleFillSymbol(); ipSymbol = (ISymbol)ipSimpleFillSymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipColor.Red = 0; ipColor.Blue = 255; ipColor.Green = 0; ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; ipSimpleFillSymbol.Color = ipColor; } else if (type == esriGeometryType.esriGeometryPoint || type == esriGeometryType.esriGeometryMultipoint) { ipSimpleMarkersymbol = new SimpleMarkerSymbol(); ipSymbol = (ISymbol)ipSimpleMarkersymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipSimpleMarkersymbol.Color = ipColor; ipSimpleMarkersymbol.Size = 8; } pMapControl.FlashShape(pGeometry, 2, 100, ipSymbol); }
public void Init(int type) { if (type == 1) { this.m_colspace = 0.1; this.m_rowspace = 0.1; this.m_itemwidth = 1; this.m_itemheight = 1; this.m_space = 0.1; } ISymbol simpleMarkerSymbolClass = new SimpleMarkerSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleMarkerSymbol).Style = esriSimpleMarkerStyle.esriSMSCircle; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("圆"); simpleMarkerSymbolClass = new SimpleMarkerSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleMarkerSymbol).Style = esriSimpleMarkerStyle.esriSMSCross; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("十字形"); simpleMarkerSymbolClass = new SimpleMarkerSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleMarkerSymbol).Style = esriSimpleMarkerStyle.esriSMSDiamond; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("菱形"); simpleMarkerSymbolClass = new SimpleLineSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleLineSymbol).Style = esriSimpleLineStyle.esriSLSDashDot; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("线"); simpleMarkerSymbolClass = new SimpleLineSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleLineSymbol).Style = esriSimpleLineStyle.esriSLSSolid; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("线2"); simpleMarkerSymbolClass = new SimpleLineSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleLineSymbol).Style = esriSimpleLineStyle.esriSLSDashDot; (simpleMarkerSymbolClass as ISimpleLineSymbol).Width = 3; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("线3"); simpleMarkerSymbolClass = new SimpleFillSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleFillSymbol).Style = esriSimpleFillStyle.esriSFSBackwardDiagonal; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("面1"); simpleMarkerSymbolClass = new SimpleFillSymbol() as ISymbol; (simpleMarkerSymbolClass as ISimpleFillSymbol).Style = esriSimpleFillStyle.esriSFSHorizontal; this.m_symbolLists.Add(simpleMarkerSymbolClass); this.m_symbolDescriptions.Add("面2"); }
// Create four point graphics on the map in the center of four equal quadrants private async Task CreatePointGraphics() { await mapView.LayersLoadedAsync(); var height = mapView.Extent.Height / 4; var width = mapView.Extent.Width / 4; var center = mapView.Extent.GetCenter(); var topLeft = new MapPoint(center.X - width, center.Y + height, mapView.SpatialReference); var topRight = new MapPoint(center.X + width, center.Y + height, mapView.SpatialReference); var bottomLeft = new MapPoint(center.X - width, center.Y - height, mapView.SpatialReference); var bottomRight = new MapPoint(center.X + width, center.Y - height, mapView.SpatialReference); var symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Diamond }; graphicsLayer.Graphics.Add(new Graphic() { Geometry = topLeft, Symbol = symbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = topRight, Symbol = symbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = bottomLeft, Symbol = symbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = bottomRight, Symbol = symbol }); }
private static bool CreateEditGeometry() { if (_editGeometry == null && View.Instance != null && View.Instance.Map != null) { SimpleMarkerSymbol vertexSymbol = new SimpleMarkerSymbol() { Color = new SolidColorBrush(Color.FromArgb(255, 225, 225, 225)), OutlineColor = new SolidColorBrush(Colors.Black), OutlineThickness = 1, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square, Size = 10 }; _editGeometry = new EditGeometry { Map = View.Instance.Map, IsEnabled = true, VertexSymbol = vertexSymbol }; return true; } return false; }
// Create four point graphics on the map in the center of four equal quadrants private void MyMapView_NavigationCompleted(object sender, EventArgs e) { MyMapView.NavigationCompleted -= MyMapView_NavigationCompleted; try { // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var myViewpointExtent = viewpointExtent; var height = myViewpointExtent.Height / 4; var width = myViewpointExtent.Width / 4; var center = myViewpointExtent.GetCenter(); var topLeft = new MapPoint(center.X - width, center.Y + height, MyMapView.SpatialReference); var topRight = new MapPoint(center.X + width, center.Y + height, MyMapView.SpatialReference); var bottomLeft = new MapPoint(center.X - width, center.Y - height, MyMapView.SpatialReference); var bottomRight = new MapPoint(center.X + width, center.Y - height, MyMapView.SpatialReference); var symbol = new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Diamond }; _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = topLeft, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = topRight, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = bottomLeft, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = bottomRight, Symbol = symbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = new MapPoint(0, 0), Symbol = new SimpleMarkerSymbol() { Size = 15, Color = Colors.Blue } }); } catch (Exception ex) { MessageBox.Show("Error occured : " + ex.Message, "Create Points Sample"); } }
public Viewshed() { InitializeComponent(); // Initialize the tap points graphics collection TapPoints = new ObservableCollection<Graphic>(); // Initialize layers Layers = new LayerCollection(); // Create the basemap layer and add it to the map Layers.Add(new ArcGISTiledMapServiceLayer() { ServiceUri = "http://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer" }); // Symbol for tap points layer SimpleLineSymbol tapPointsOutline = new SimpleLineSymbol() { Color = Colors.Black }; SimpleMarkerSymbol tapPointsSymbol = new SimpleMarkerSymbol() { Color = Colors.White, Outline = tapPointsOutline }; // Tap points layer m_tapPointsLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = tapPointsSymbol } }; // Bind the TapPoints property to the GraphicsSource of the tap points layer Binding b = new Binding("TapPoints") { Source = this }; BindingOperations.SetBinding(m_tapPointsLayer, GraphicsLayer.GraphicsSourceProperty, b); // Add the layer to the map Layers.Add(m_tapPointsLayer); // Set the data context to the page instance to allow for binding to the page's properties // in its XAML DataContext = this; }
public MainWindow() { InitializeComponent(); //===================================================== // Add graphics individually //===================================================== // get the graphics layer GraphicsLayer graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer; this.random = new Random(); // create a stopwatch Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); // create a bunch of graphics for (int i = 0; i < 50000; i++) { int latitude = random.Next(-90, 90); int longitude = random.Next(-180, 180); MapPoint mapPoint = new MapPoint(longitude, latitude); SimpleMarkerSymbol sms = new SimpleMarkerSymbol(); sms = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol(); sms.Color = System.Windows.Media.Colors.Red; sms.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Circle; sms.Size = 2; Graphic graphic = new Graphic(mapPoint, sms); graphicsLayer.Graphics.Add(graphic); } // stop timing stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Console.WriteLine("Time elapsed: {0}", stopWatch.Elapsed); //////======================================================= //// Simple Renderer ////======================================================== //// get the graphics layer //GraphicsLayer graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer; //this.random = new Random(); //// create a stopwatch //Stopwatch stopWatch = new Stopwatch(); //stopWatch.Start(); //SimpleMarkerSymbol sms = new SimpleMarkerSymbol(); //sms = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol(); //sms.Color = System.Windows.Media.Colors.Red; //sms.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Circle; //sms.Size = 2; //SimpleRenderer simpleRenderer = new SimpleRenderer(); //simpleRenderer.Symbol = sms; //// create a enerable list //List<Graphic> graphics = new List<Graphic>(50001); //// create a bunch of graphics //for (int i = 0; i < 50000; i++) //{ // int latitude = random.Next(-90, 90); // int longitude = random.Next(-180, 180); // MapPoint mapPoint = new MapPoint(longitude, latitude); // Graphic graphic = new Graphic(mapPoint); // graphics.Add(graphic); //} //graphicsLayer.Renderer = simpleRenderer; //graphicsLayer.GraphicsSource = graphics; ; //// stop timing //stopWatch.Stop(); //TimeSpan ts = stopWatch.Elapsed; //Console.WriteLine("Time elapsed: {0}", stopWatch.Elapsed); ////======================================================= //// Add using GraphicsSource ////======================================================== //// get the graphics layer //GraphicsLayer graphicsLayer = MyMapView.Map.Layers["graphicsLayer"] as GraphicsLayer; //this.random = new Random(); //// create a stopwatch //Stopwatch stopWatch = new Stopwatch(); //stopWatch.Start(); //// create a enerable list //List<Graphic> graphics = new List<Graphic>(50001); //// create a bunch of graphics //for (int i = 0; i < 50000; i++) //{ // int latitude = random.Next(-90, 90); // int longitude = random.Next(-180, 180); // MapPoint mapPoint = new MapPoint(longitude, latitude); // SimpleMarkerSymbol sms = new SimpleMarkerSymbol(); // sms = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol(); // sms.Color = System.Windows.Media.Colors.Red; // sms.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Circle; // sms.Size = 2; // Graphic graphic = new Graphic(mapPoint, sms); // graphics.Add(graphic); //} //graphicsLayer.GraphicsSource = graphics; ; //// stop timing //stopWatch.Stop(); //TimeSpan ts = stopWatch.Elapsed; //Console.WriteLine("Time elapsed: {0}", stopWatch.Elapsed); }
/// <summary> /// Create the temporary layer from the results of the Query /// </summary> /// <returns>Temporary <see cref="ESRI.ArcGIS.Client.FeatureLayer"/></returns> /// <remarks>Uses "temporary" symbols to render the points, lines, or polygons. The temporary /// layer is not displayed in the Map Contents panel, but the attribute grid opens to show the feature attributes.</remarks> private FeatureLayer CreateTempLayer() { // Check that the results layer is not null and use the results layer to create the temporary layer if (resultsLayer != null) { temporaryLayer = resultsLayer; // ControlTemplate to create ellipse for temporary point symbol var template = (ControlTemplate)System.Windows.Markup.XamlReader.Load("<ControlTemplate " + "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" " + "xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + "<Grid RenderTransformOrigin=\"{Binding Symbol.RenderTransformPoint}\">" + "<Ellipse " + "Fill=\"#99FFFFFF\" " + "Width=\"21\" " + "Height=\"21\" " + "Stroke=\"Red\" " + "StrokeThickness=\"2\">" + "</Ellipse>" + "<Ellipse Fill=\"#99FFFFFF\" " + "Width=\"3\" " + "Height=\"3\" " + "Stroke=\"Red\" " + "StrokeThickness=\"2\">" + "</Ellipse>" + "</Grid> " + "</ControlTemplate>"); Symbol test = new SimpleMarkerSymbol(); // Set the renderers to a "temporary" look for the temp Layer if (temporaryLayer.LayerInfo.GeometryType == GeometryType.Point || temporaryLayer.LayerInfo.GeometryType == GeometryType.MultiPoint) temporaryLayer.Renderer = new SimpleRenderer() { Symbol = new MarkerSymbol() { ControlTemplate = template as ControlTemplate, OffsetX = 10, OffsetY = 10 } }; else if (temporaryLayer.LayerInfo.GeometryType == GeometryType.Polyline) temporaryLayer.Renderer = new SimpleRenderer() { Symbol = new SimpleLineSymbol() { Color = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)), Width = 3 } }; else if (temporaryLayer.LayerInfo.GeometryType == GeometryType.Polygon) temporaryLayer.Renderer = new SimpleRenderer() { Symbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(Color.FromArgb(80, 255, 255, 255)), BorderBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0)), BorderThickness = 3 } }; // Specify a name to set the ID property on the Layer. This name is associated with the layer but does not display in the map contents panel string tempLayerID = string.Format(Strings.RelatedTo, temporaryLayer.LayerInfo.Name, PopupInfo.PopupItem.Title); MapApplication.SetLayerName(temporaryLayer, tempLayerID); LayerProperties.SetIsVisibleInMapContents(temporaryLayer, false); } return temporaryLayer; }
private async void LoadBusMap_Click(object sender, RoutedEventArgs e) { var from = await this.FindAddress("32 arlington road, lake ronkonkoma, ny"); var to = await this.FindAddress("50 gettysburg drive, port jefferson, ny"); try { if (from == null) { throw new Exception("Unable to find a match for '" + "'."); } if (to == null) { throw new Exception("Unable to find a match for '" + "'."); } // get the RouteResults graphics layer; add the from/to graphics var routeGraphics = MyMap.Layers["RouteResults"] as GraphicsLayer; if (routeGraphics == null) { throw new Exception("A graphics layer named 'RouteResults' was not found in the map."); } // code here to show address locations on the map var fromMapPoint = GeometryEngine.Project(from.Geometry, new SpatialReference(4326)); var toMapPoint = GeometryEngine.Project(to.Geometry, new SpatialReference(4326)); var fromSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Size = 16, Color = Colors.Green }; var toSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.Circle, Size = 16, Color = Colors.Red }; var fromMapGraphic = new Graphic { Geometry = fromMapPoint, Symbol = fromSym }; var toMapGraphic = new Graphic { Geometry = toMapPoint, Symbol = toSym }; routeGraphics.Graphics.Add(fromMapGraphic); routeGraphics.Graphics.Add(toMapGraphic); } catch (Exception exp) { //this.DirectionsTextBlock.Text = exp.Message; } }
/// <summary> /// Adds a graphic element to the map graphics container /// </summary> /// <param name="geom">IGeometry</param> internal void AddGraphicToMap(IGeometry geom, IColor color, bool IsTempGraphic = false, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSCircle, esriRasterOpCode rasterOpCode = esriRasterOpCode.esriROPNOP) { if (geom == null || ArcMap.Document == null || ArcMap.Document.FocusMap == null) return; IElement element = null; double width = 2.0; geom.Project(ArcMap.Document.FocusMap.SpatialReference); if(geom.GeometryType == esriGeometryType.esriGeometryPoint) { // Marker symbols var simpleMarkerSymbol = new SimpleMarkerSymbol() as ISimpleMarkerSymbol; simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = color; simpleMarkerSymbol.Size = 5; simpleMarkerSymbol.Style = markerStyle; var markerElement = new MarkerElement() as IMarkerElement; markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; } else if(geom.GeometryType == esriGeometryType.esriGeometryPolyline) { // create graphic then add to map var lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Width = width; if (IsTempGraphic && rasterOpCode != esriRasterOpCode.esriROPNOP) { lineSymbol.Width = 1; lineSymbol.ROP2 = rasterOpCode; } var le = new LineElementClass() as ILineElement; element = le as IElement; le.Symbol = lineSymbol; } if (element == null) return; IClone clone = geom as IClone; element.Geometry = clone as IGeometry; var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var gc = av as IGraphicsContainer; // store guid var eprop = element as IElementProperties; eprop.Name = Guid.NewGuid().ToString(); if (this is LinesViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Line, eprop.Name, geom, IsTempGraphic)); else if (this is CircleViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Circle, eprop.Name, geom, IsTempGraphic)); else if (this is EllipseViewModel) GraphicsList.Add(new Graphic(GraphicTypes.Ellipse, eprop.Name, geom, IsTempGraphic)); else if (this is RangeViewModel) GraphicsList.Add(new Graphic(GraphicTypes.RangeRing, eprop.Name, geom, IsTempGraphic)); gc.AddElement(element, 0); //refresh map av.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); if (!IsTempGraphic) RaisePropertyChanged(() => HasMapGraphics); }
private Esri.ArcGISRuntime.Symbology.Symbol GetPointSymbol(SurfacePlacement mode) { SimpleMarkerSymbol sms = new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = mode == SurfacePlacement.Absolute ? Colors.Red : mode == SurfacePlacement.Draped ? Colors.Yellow : Colors.LightBlue, Size = 20 }; return sms; }
public ManeuverViewModel(Graphic fromGraphic, Graphic toGraphic, int number) { if (number == 1) Label = "A"; else if (toGraphic.Attributes["maneuverType"].ToString() == "esriDMTStop") Label = "B"; else Label = number.ToString(); SetupGraphic(toGraphic, fromGraphic); SegmentGraphic = toGraphic; SegmentGraphic.Symbol = new SimpleLineSymbol() { Style = SimpleLineSymbol.LineStyle.Solid, Color = new SolidColorBrush(Color.FromRgb(204, 204, 0)), Width = 7 }; Directions = string.Format("{0}. {1}", number, toGraphic.Attributes["text"]); if (fromGraphic != null) { var distance = Math.Round(Convert.ToDouble(fromGraphic.Attributes["length"]), 1); if (distance != 0) Distance = string.Format("{0} {1}", distance, "miles"); } _ManeuverMarkerSymbol = new SimpleMarkerSymbol() { Size = 20, Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle }; }
private void OnFlashPointCommand(object obj) { if(amCoordGetter != null && amCoordGetter.Point != null) { IGeometry address = amCoordGetter.Point; // Map und View IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument; IActiveView activeView = mxdoc.ActivatedView; IMap map = mxdoc.FocusMap; IEnvelope envelope = activeView.Extent; ClearGraphicsContainer(map); IScreenDisplay screenDisplay = activeView.ScreenDisplay; short screenCache = Convert.ToInt16(esriScreenCache.esriNoScreenCache); ISpatialReference outgoingCoordSystem = map.SpatialReference; address.Project(outgoingCoordSystem); IRgbColor color = new RgbColorClass(); color.Green = 80; color.Red = 22; color.Blue = 68; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IElement element = null; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; IPolygon poly = null; if (InputCoordinateType == CoordinateType.MGRS || InputCoordinateType == CoordinateType.USNG) { poly = GetMGRSPolygon(address as IPoint); } if (poly != null) { address = poly; } var av = mxdoc.FocusMap as IActiveView; FlashGeometry(address, color, av.ScreenDisplay, 500); AddElement(map, address); // do not center if in layout view if (mxdoc.ActiveView is IMap) { if (poly != null && !poly.IsEmpty && (poly as IArea) != null) envelope.CenterAt((poly as IArea).Centroid); else envelope.CenterAt(amCoordGetter.Point); activeView.Extent = envelope; activeView.Refresh(); } } }
private void AddElement(IMap map, IGeometry geom) { IGraphicsContainer graphicsContainer = map as IGraphicsContainer; IRgbColor color = new RgbColorClass(); color.Green = 80; color.Red = 22; color.Blue = 68; IElement element = null; if (geom is IPoint) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; if (element != null) { element.Geometry = geom; } } else if(geom is IPolygon) { var temp = new SimpleLineSymbol(); temp.Color = color; temp.Style = esriSimpleLineStyle.esriSLSSolid; temp.Width = 2; var s = new SimpleFillSymbol(); s.Color = color; s.Outline = temp; s.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal; var pe = new PolygonElementClass(); element = pe as IElement; var fill = pe as IFillShapeElement; fill.Symbol = s; element.Geometry = geom; } graphicsContainer.AddElement(element, 0); IActiveView activeView = map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public async void Search(int wkid) { // Create the symbol SimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbol(); markerSymbol.Size = 15; markerSymbol.Color = Colors.Green; markerSymbol.Style = SimpleMarkerStyle.Diamond; SimpleFillSymbol sfsState = new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }; SimpleFillSymbol sfsCounty = new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }; SpatialReference sr = new SpatialReference(wkid); Query queryCity = new Query("areaname = '" + this.SearchText + "'"); queryCity.OutSpatialReference = sr; queryCity.OutFields.Add("*"); QueryTask queryTaskCity = new QueryTask(new System.Uri(this.USAUri + "/0")); QueryResult queryResultCity = await queryTaskCity.ExecuteAsync(queryCity); Query queryStates = new Query("state_name = '" + this.SearchText + "'"); queryStates.OutSpatialReference = sr; queryStates.OutFields.Add("*"); QueryTask queryTaskStates = new QueryTask(new System.Uri(this.USAUri + "/2")); QueryResult queryResultStates = await queryTaskStates.ExecuteAsync(queryStates); Query queryCounties = new Query("name = '" + this.SearchText + "'"); queryCounties.OutSpatialReference = sr; queryCounties.OutFields.Add("*"); QueryTask queryTaskCounties = new QueryTask(new System.Uri(this.USAUri + "/3")); QueryResult queryResultCounties= await queryTaskCounties.ExecuteAsync(queryCounties); // Get the list of features (graphics) from the result IReadOnlyList<Feature> featuresCity = queryResultCity.FeatureSet.Features; foreach (Feature featureCity in featuresCity) { Graphic graphicCity = (Graphic)featureCity; graphicCity.Symbol = markerSymbol; this.graphicsLayerCity.Graphics.Add(graphicCity); } // Get the list of features (graphics) from the result IReadOnlyList<Feature> featuresStates = queryResultStates.FeatureSet.Features; foreach (Feature featureState in featuresStates) { Graphic graphicState = (Graphic)featureState; graphicState.Symbol = sfsState; this.graphicsLayerState.Graphics.Add(graphicState); } // Get the list of features (graphics) from the result IReadOnlyList<Feature> featuresCounties = queryResultCounties.FeatureSet.Features; foreach (Feature featureCounty in featuresCounties) { Graphic graphicCounty = (Graphic)featureCounty; graphicCounty.Symbol = sfsCounty; this.graphicsLayerCounty.Graphics.Add(graphicCounty); } }
private void AddElement(IMap map, IPoint point) { IGraphicsContainer graphicsContainer = map as IGraphicsContainer; IRgbColor color = new RgbColorClass(); color.Green = 80; color.Red = 22; color.Blue = 68; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IElement element = null; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; if (element != null) { element.Geometry = point; } graphicsContainer.AddElement(element, 0); //Flag the new text to invalidate. IActiveView activeView = map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }