private void Initialize() { // Create new Map with basemap Map myMap = new Map(Basemap.CreateTopographic()); // Create and set initial map location MapPoint initialLocation = new MapPoint( -11000000, 5000000, SpatialReferences.WebMercator); myMap.InitialViewpoint = new Viewpoint(initialLocation, 100000000); // Create feature table using a url _featureTable = new ServiceFeatureTable(new Uri(_statesUrl)); // Create feature layer using this feature table _featureLayer = new FeatureLayer(_featureTable); // Set the Opacity of the Feature Layer _featureLayer.Opacity = 0.6; // Create a new renderer for the States Feature Layer SimpleLineSymbol lineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, Color.Black, 1); SimpleFillSymbol fillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, Color.Yellow, lineSymbol); // Set States feature layer renderer _featureLayer.Renderer = new SimpleRenderer(fillSymbol); // Add feature layer to the map myMap.OperationalLayers.Add(_featureLayer); // Assign the map to the MapView _myMapView.Map = myMap; }
// Create polyline graphics on the map in the center and 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 length = 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 redSymbol = new SimpleLineSymbol() { Color = Colors.Red, Width = 4, Style = SimpleLineStyle.Solid }; var blueSymbol = new SimpleLineSymbol() { Color = Colors.Blue, Width = 4, Style = SimpleLineStyle.Solid }; _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(center, length), Symbol = blueSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topLeft, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topRight, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomLeft, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomRight, length), Symbol = redSymbol }); } catch (Exception ex) { var _x = new MessageDialog("Error occurred : " + ex.Message, "Sample Error").ShowAsync(); } }
protected override void OnClick() { IMxDocument pMxDoc = ArcMap.Application.Document as IMxDocument; IMap pMap = pMxDoc.FocusMap; IFeatureLayer pFeatLayer = pMap.Layer[0] as IFeatureLayer; IFeatureSelection featSel = pFeatLayer as IFeatureSelection; ISimpleFillSymbol polySym = new SimpleFillSymbol(); IRgbColor pColor = new RgbColor(); pColor.Red = 0; pColor.Green = 250; pColor.Blue = 0; IRgbColor pOutColor = new RgbColor(); pOutColor.Red = 0; pOutColor.Green = 0; pOutColor.Blue = 250; ILineSymbol pLineSym = new SimpleLineSymbol(); pLineSym.Color = pOutColor; pLineSym.Width = 2; polySym.Color = pColor; polySym.Outline = pLineSym; featSel.SetSelectionSymbol = true; featSel.SelectionSymbol = polySym as ISymbol; // ArcMap.Application.CurrentTool = null; }
// Create polyline graphics on the map in the center and the center of four equal quadrants void MyMapView_SpatialReferenceChanged(object sender, EventArgs e) { MyMapView.SpatialReferenceChanged -= MyMapView_SpatialReferenceChanged; try { // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var height = viewpointExtent.Height / 4; var width = viewpointExtent.Width / 4; var length = width / 4; var center = viewpointExtent.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 redSymbol = new SimpleLineSymbol() { Color = Colors.Red, Width = 4, Style = SimpleLineStyle.Solid }; var blueSymbol = new SimpleLineSymbol() { Color = Colors.Blue, Width = 4, Style = SimpleLineStyle.Solid }; _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(center, length), Symbol = blueSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topLeft, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topRight, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomLeft, length), Symbol = redSymbol }); _graphicsOverlay.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomRight, length), Symbol = redSymbol }); } 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.CreateTopographic()); // Create uri to the used feature service var serviceUri = new Uri( "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"); // Create service feature table ServiceFeatureTable statesFeatureTable = new ServiceFeatureTable(serviceUri); // Create a new feature layer using the service feature table FeatureLayer statesLayer = new FeatureLayer(statesFeatureTable); // Create a new unique value renderer UniqueValueRenderer regionRenderer = new UniqueValueRenderer(); // Add the "SUB_REGION" field to the renderer regionRenderer.FieldNames.Add("SUB_REGION"); // Define a line symbol to use for the region fill symbols SimpleLineSymbol stateOutlineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, System.Drawing.Color.White, 0.7); // Define distinct fill symbols for a few regions (use the same outline symbol) SimpleFillSymbol pacificFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.Blue, stateOutlineSymbol); SimpleFillSymbol mountainFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.LawnGreen, stateOutlineSymbol); SimpleFillSymbol westSouthCentralFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.SandyBrown, stateOutlineSymbol); // Add values to the renderer: define the label, description, symbol, and attribute value for each regionRenderer.UniqueValues.Add( new UniqueValue("Pacific", "Pacific Region", pacificFillSymbol, "Pacific")); regionRenderer.UniqueValues.Add( new UniqueValue("Mountain", "Rocky Mountain Region", mountainFillSymbol, "Mountain")); regionRenderer.UniqueValues.Add( new UniqueValue("West South Central", "West South Central Region", westSouthCentralFillSymbol, "West South Central")); // Set the default region fill symbol (transparent with no outline) for regions not explicitly defined in the renderer SimpleFillSymbol defaultFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Null, System.Drawing.Color.Transparent, null); regionRenderer.DefaultSymbol = defaultFillSymbol; regionRenderer.DefaultLabel = "Other"; // Apply the unique value renderer to the states layer statesLayer.Renderer = regionRenderer; // Add created layer to the map myMap.OperationalLayers.Add(statesLayer); // Assign the map to the MapView _myMapView.Map = myMap; // Feature table initialization statesFeatureTable.RetryLoadAsync(); }
/// <summary>Construct Generate Renderer sample control</summary> public GenerateRenderer() { InitializeComponent(); var lineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Width = 0.5 }; _baseSymbol = new SimpleFillSymbol() { Color = Colors.Transparent, Outline = lineSymbol, Style = SimpleFillStyle.Solid }; MyMapView.ExtentChanged += MyMapView_ExtentChanged; }
// Create marker symbols private async Task SetupSymbolsAsync() { try { const int size = 24; // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = 15, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = 15, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = 15, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = 15, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List<Task> setSourceTasks = new List<Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedPushpin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size, XOffset = 0, YOffset = 0 }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols.OfType<SimpleMarkerSymbol>() .Select(sym => sym.CreateSwatchAsync(size, size, 96.0, Colors.Transparent)) .ToArray(); var imageSources = new List<ImageSource>(await Task.WhenAll(swatchTasks)); // Manually create swatches for the picture marker symbols imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedStickpin.png", size)); imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/RedPushpin.png", size)); imageSources.Add(LoadImage("pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png", size)); symbolCombo.ItemsSource = imageSources; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
/// <summary>Construct Generate Renderer sample control</summary> public GenerateRenderer() { InitializeComponent(); var lineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Width = 0.5 }; _baseSymbol = new SimpleFillSymbol() { Color = Colors.Transparent, Outline = lineSymbol, Style = SimpleFillStyle.Solid }; _featureLayer = MyMapView.Map.Layers["FeatureLayer"] as FeatureLayer; ((ServiceFeatureTable)_featureLayer.FeatureTable).OutFields = new OutFields( new string[] { "POP2007, POP07_SQMI, WHITE, BLACK, AMERI_ES, ASIAN, HAWN_PI, OTHER, MULT_RACE, HISPANIC, STATE_NAME, NAME" }); MyMapView.SpatialReferenceChanged += MyMapView_SpatialReferenceChanged; }
// Creates a two-part polygon and a four-part polyline to use as test graphics for the Boundary method private void CreateTestGraphics() { var center = MyMapView.Extent.GetCenter(); var width = MyMapView.Extent.Width / 4; var left = new MapPoint(center.X - width, center.Y, MyMapView.SpatialReference); var right = new MapPoint(center.X + width, center.Y, MyMapView.SpatialReference); var fillSymbol = new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }; var lineSymbol = new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Solid, Width = 2 }; _testGraphics.Graphics.Add(new Graphic() { Geometry = CreatePolygonBox(left, width), Symbol = fillSymbol }); _testGraphics.Graphics.Add(new Graphic() { Geometry = CreatePolylineBox(right, width), Symbol = lineSymbol }); }
/// <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; }
/// <summary> /// Initializes a new instance of the ViewshedViewModel class. /// </summary> public ClipViewModel() { this.ClipRelayCommand = new RelayCommand(Clip); Messenger.Default.Register<Esri.ArcGISRuntime.Controls.MapView>(this, (mapView) => { this.mapView = mapView; this.simpleInputLineSymbol = new SimpleLineSymbol(); this.simpleInputLineSymbol.Color = System.Windows.Media.Colors.Red; this.simpleInputLineSymbol.Width = 2; this.simpleInputLineSymbol.Style = SimpleLineStyle.Solid; this.simpleResultLineSymbol = new SimpleLineSymbol(); this.simpleResultLineSymbol.Color = (Color)ColorConverter.ConvertFromString("#FF0000FF"); this.simpleResultFillSymbol = new SimpleFillSymbol(); this.simpleResultFillSymbol.Color = (Color)ColorConverter.ConvertFromString("#770000FF"); this.simpleResultFillSymbol.Outline = this.simpleResultLineSymbol; this.simpleResultRenderer = new SimpleRenderer(); this.simpleResultRenderer.Symbol = this.simpleResultFillSymbol; this.inputLineRenderer = new SimpleRenderer(); this.inputLineRenderer.Symbol = this.simpleInputLineSymbol; this.localGPService = new LocalGeoprocessingService(this.clipGPKPath, GeoprocessingServiceType.SubmitJob); this.localGPService.StartAsync(); this.resultGraphicsLayer = new GraphicsLayer(); this.resultGraphicsLayer.ID = "Clip Result"; this.resultGraphicsLayer.DisplayName = "Viewshed"; this.resultGraphicsLayer.Renderer = this.simpleResultRenderer; this.resultGraphicsLayer.InitializeAsync(); this.inputGraphicsLayer = new GraphicsLayer(); this.inputGraphicsLayer.ID = "Input Line"; this.inputGraphicsLayer.DisplayName = "Input Line"; this.inputGraphicsLayer.Renderer = this.inputLineRenderer; this.inputGraphicsLayer.InitializeAsync(); this.mapView.Map.Layers.Add(this.inputGraphicsLayer); this.mapView.Map.Layers.Add(this.resultGraphicsLayer); }); }
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; }
//��˸�� public static void FlashLine(IMapControlDefault mapControl, IScreenDisplay iScreenDisplay, IGeometry iGeometry) { ISimpleLineSymbol iLineSymbol; ISymbol iSymbol; IRgbColor iRgbColor; iLineSymbol = new SimpleLineSymbol(); iLineSymbol.Width = 4; iRgbColor = new RgbColor(); iRgbColor.Red = 255; iLineSymbol.Color = iRgbColor; iSymbol = (ISymbol)iLineSymbol; iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; mapControl.FlashShape(iGeometry, 5, 300, iSymbol); }
// Create marker symbols private async Task SetupSymbolsAsync() { try { int size = Convert.ToInt32(LayoutRoot.Resources["ImageSize"]); int sizePt = (int)((float)size / DisplayInformation.GetForCurrentView().LogicalDpi * 72); // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = sizePt, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = sizePt, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = sizePt, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = sizePt, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List<Task> setSourceTasks = new List<Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("http://static.arcgis.com/images/Symbols/Basic/RedShinyPin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols .Select(sym => sym.CreateSwatchAsync()) .ToArray(); symbolCombo.ItemsSource = await Task.WhenAll(swatchTasks); symbolCombo.SelectedIndex = 0; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private void OnOverrideButtonClicked(object sender, EventArgs e) { // Create a symbol to be used in the renderer SimpleLineSymbol symbol = new SimpleLineSymbol() { Color = Colors.Blue, Width = 2, Style = SimpleLineSymbolStyle.Solid }; // Create a new renderer using the symbol just created SimpleRenderer renderer = new SimpleRenderer(symbol); // Assign the new renderer to the feature layer _featureLayer.Renderer = renderer; }
// Creates a two-part polygon and a four-part polyline to use as test graphics for the Boundary method private void CreateTestGraphics() { // Get current viewpoints extent from the MapView var currentViewpoint = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry); var viewpointExtent = currentViewpoint.TargetGeometry.Extent; var center = viewpointExtent.GetCenter(); var width = viewpointExtent.Width / 4; var left = new MapPoint(center.X - width, center.Y, MyMapView.SpatialReference); var right = new MapPoint(center.X + width, center.Y, MyMapView.SpatialReference); var fillSymbol = new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }; var lineSymbol = new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Solid, Width = 2 }; _testGraphics.Graphics.Add(new Graphic() { Geometry = CreatePolygonBox(left, width), Symbol = fillSymbol }); _testGraphics.Graphics.Add(new Graphic() { Geometry = CreatePolylineBox(right, width), Symbol = lineSymbol }); }
// Create polyline graphics on the map in the center and the center of four equal quadrants private async Task CreatePolylineGraphics() { await mapView.LayersLoadedAsync(); var height = mapView.Extent.Height / 4; var width = mapView.Extent.Width / 4; var length = 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 redSymbol = new SimpleLineSymbol() { Color = Colors.Red, Width = 4, Style = SimpleLineStyle.Solid }; var blueSymbol = new SimpleLineSymbol() { Color = Colors.Blue, Width = 4, Style = SimpleLineStyle.Solid }; graphicsLayer.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(center, length), Symbol = blueSymbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topLeft, length), Symbol = redSymbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(topRight, length), Symbol = redSymbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomLeft, length), Symbol = redSymbol }); graphicsLayer.Graphics.Add(new Graphic() { Geometry = CreatePolylineX(bottomRight, length), Symbol = redSymbol }); }
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; }
// Create line / fill symbols private async Task SetupSymbolsAsync() { try { // Create symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<SampleSymbol>() { new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Dash, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.DashDot, Width = 4 }), new SampleSymbol(new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 255, 0), Style = SimpleFillStyle.DiagonalCross, Outline = blackOutlineSymbol }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 0, 255), Style = SimpleFillStyle.Vertical, Outline = blackOutlineSymbol }), new SampleSymbol(new PictureFillSymbol() { Outline = blackOutlineSymbol }, "pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png") }; // Set image sources for picture fill symbols await Task.WhenAll(_symbols.Where(s => s.Symbol is PictureFillSymbol) .Select(s => ((PictureFillSymbol)s.Symbol).SetSourceAsync(s.SymbolUri))); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols .Select(sym => sym.Symbol.CreateSwatchAsync(24, 24, 96.0, Colors.Transparent)) .ToArray(); symbolCombo.ItemsSource = new List<ImageSource>(await Task.WhenAll(swatchTasks)); } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private async void Initialize() { try { // Get the paths to resources used by the sample. string basemapTilePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "streetmap_SD.tpkx"); string networkGeodatabasePath = DataManager.GetDataFolder("567e14f3420d40c5a206e5c0284cf8fc", "sandiego.geodatabase"); // Create the tile cache representing the offline basemap. TileCache tiledBasemapCache = new TileCache(basemapTilePath); // Create a tiled layer to display the offline tiles. ArcGISTiledLayer offlineTiledLayer = new ArcGISTiledLayer(tiledBasemapCache); // Create a basemap based on the tile layer. Basemap offlineBasemap = new Basemap(offlineTiledLayer); // Create a new map with the offline basemap. Map theMap = new Map(offlineBasemap); // Set the initial viewpoint to show the routable area. theMap.InitialViewpoint = new Viewpoint(_routableArea); // Show the map in the map view. MyMapView.Map = theMap; // Create overlays for displaying the stops and the calculated route. _stopsOverlay = new GraphicsOverlay(); _routeOverlay = new GraphicsOverlay(); // Create a symbol and renderer for symbolizing the calculated route. SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Blue, 2); _routeOverlay.Renderer = new SimpleRenderer(routeSymbol); // Add the stops and route overlays to the map. MyMapView.GraphicsOverlays.Add(_stopsOverlay); MyMapView.GraphicsOverlays.Add(_routeOverlay); // Create the route task, referring to the offline geodatabase with the street network. _offlineRouteTask = await RouteTask.CreateAsync(networkGeodatabasePath, "Streets_ND"); // Get the list of available travel modes. _availableTravelModes = _offlineRouteTask.RouteTaskInfo.TravelModes.ToList(); // Update the UI with the travel modes list. TravelModesCombo.ItemsSource = _availableTravelModes.ToList(); TravelModesCombo.SelectedIndex = 0; // Create the default parameters. _offlineRouteParameters = await _offlineRouteTask.CreateDefaultParametersAsync(); // Display the extent of the road network on the map. DisplayBoundaryMarker(); // Now that the sample is ready, hook up the tap event. MyMapView.GeoViewTapped += MapView_Tapped; TravelModesCombo.SelectedIndexChanged += TravelMode_SelectionChanged; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); ShowMessage("Couldn't start sample", "There was a problem starting the sample. See debug output for details."); } }
private void RedrawGrid() { if (cellSize == 0 || columns == 0 || rows == 0) return; var tlLat = Poi.Position.Latitude; var tlLon = Poi.Position.Longitude; var width = cellSize * columns; var height = cellSize * rows; double trLat, trLon; CoordinateUtils.CalculatePointSphere2D(tlLat, tlLon, width, 90, out trLat, out trLon); double blLat, blLon; CoordinateUtils.CalculatePointSphere2D(tlLat, tlLon, height, 180, out blLat, out blLon); // Convert to map points var p = new Point(tlLon, tlLat).ToMapPoint(); tlLon = p.X; tlLat = p.Y; p = new Point(trLon, trLat).ToMapPoint(); trLon = p.X; trLat = p.Y; p = new Point(blLon, blLat).ToMapPoint(); blLon = p.X; blLat = p.Y; var deltaLat = Math.Abs(tlLat - blLat) / rows; var deltaLon = Math.Abs(trLon - tlLon) / columns; var labels = new List<string>(); for (int i = 1; i <= rows; i++) labels.Add(i.ToString()); labels.Add(""); // Empty label for last row for (int i = 1; i <= columns; i++) labels.Add(ToExcelColumnName(i)); labels.Add(""); // Empty label for last column Execute.OnUIThread(() => { var pts = new List<PointCollection>(); PointCollection labelCoordinates = new PointCollection(); PointCollection lineCoordinates; double fromLat = tlLat, fromLon = tlLon, toLat = tlLat, toLon = trLon; for (int i = 0; i <= rows; i++) { lineCoordinates = new PointCollection(); lineCoordinates.Add(new MapPoint(tlLon, fromLat)); lineCoordinates.Add(new MapPoint(trLon, fromLat)); pts.Add(lineCoordinates); labelCoordinates.Add(new MapPoint(tlLon, fromLat)); fromLat -= deltaLat; } for (int i = 0; i <= columns; i++) { lineCoordinates = new PointCollection(); lineCoordinates.Add(new MapPoint(fromLon, tlLat)); lineCoordinates.Add(new MapPoint(fromLon, blLat)); pts.Add(lineCoordinates); labelCoordinates.Add(new MapPoint(fromLon, tlLat)); fromLon += deltaLon; } var symbol = new SimpleLineSymbol { Color = SelectedColorBrush, Width = StrokeWidth, Style = SimpleLineSymbol.LineStyle.Dot }; var poiId = Poi.Id.ToString(); var graphics = new List<Graphic>(); var j = 0; foreach (var c in pts) { var pl = new Polyline(); pl.Paths.Add(c); var g = new Graphic { Symbol = symbol, Geometry = pl }; g.Attributes["ID"] = poiId; g.Attributes["NAME"] = labels[j]; graphics.Add(g); // Add label, except A or 1, as this intersects with the icon. if (!(string.Equals(labels[j], "A", StringComparison.InvariantCultureIgnoreCase) || string.Equals(labels[j], "1", StringComparison.InvariantCultureIgnoreCase))) { var gt = new Graphic { Symbol = CreateTextSymbol(labels[j]), Geometry = labelCoordinates[j] }; gt.Attributes["ID"] = poiId; graphics.Add(gt); } j++; } ClearGraphics(); GridLayer.Graphics.AddRange(graphics); }); }
private Renderer CreateRenderer(GeometryType rendererType) { // Return a simple renderer to match the geometry type provided Symbol sym = null; switch (rendererType) { case GeometryType.Point: case GeometryType.Multipoint: // Create a marker symbol sym = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Colors.Red, 18); break; case GeometryType.Polyline: // Create a line symbol sym = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Colors.Green, 3); break; case GeometryType.Polygon: // Create a fill symbol var lineSym = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.DarkBlue, 2); sym = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Colors.Cyan, lineSym); break; default: break; } // Return a new renderer that uses the symbol created above return new SimpleRenderer(sym); }
private async void Initialize() { // Create new Map Map myMap = new Map(); //########### TILED LAYER // Create uri to the tiled service var tiledLayerUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer"); // Create new tiled layer from the url ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri); // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(tiledLayer); //########### //########### DINAMYC LAYER // Create uri to the map image layer var serviceUri = new Uri( "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer"); // Create new image layer from the url ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(serviceUri) { Name = "World Cities Population" }; // Add created layer to the basemaps collection myMap.Basemap.BaseLayers.Add(imageLayer); //########### //########### FEATURE LAYER // Create feature table using a url _featureTable = new ServiceFeatureTable(new Uri(_statesUrl)); // Create feature layer using this feature table _featureLayer = new FeatureLayer(_featureTable); // Set the Opacity of the Feature Layer _featureLayer.Opacity = 0.6; // Create a new renderer for the States Feature Layer SimpleLineSymbol lineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, Colors.Black, 1); SimpleFillSymbol fillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, Colors.Yellow, lineSymbol); // Set States feature layer renderer _featureLayer.Renderer = new SimpleRenderer(fillSymbol); // Add feature layer to the map myMap.OperationalLayers.Add(_featureLayer); //########### // Assign the map to the MapView MyMapView.Map = myMap; // Wait that the image layer is loaded and sublayer information is fetched await imageLayer.LoadAsync(); // Assign sublayers to the listview sublayerListView.ItemsSource = imageLayer.Sublayers; }
// Create line / fill symbols private async Task SetupSymbolsAsync() { try { // Create symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List <SampleSymbol>() { new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Dash, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.DashDot, Width = 4 }), new SampleSymbol(new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 255, 0), Style = SimpleFillStyle.DiagonalCross, Outline = blackOutlineSymbol }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 0, 255), Style = SimpleFillStyle.Vertical, Outline = blackOutlineSymbol }), new SampleSymbol(new PictureFillSymbol() { Outline = blackOutlineSymbol, Width = 24, Height = 24 }, "pack://application:,,,/ArcGISRuntimeSDKDotNet_DesktopSamples;component/Assets/x-24x24.png"), new SampleSymbol(new PictureFillSymbol() { Outline = blackOutlineSymbol, Width = 24, Height = 24 }, "http://static.arcgis.com/images/Symbols/Cartographic/esriCartographyMarker_79_Blue.png") }; // Set image sources for picture fill symbols await Task.WhenAll(_symbols.Where(s => s.Symbol is PictureFillSymbol) .Select(s => ((PictureFillSymbol)s.Symbol).SetSourceAsync(s.SymbolUri))); // Create image swatches for the UI Task <ImageSource>[] swatchTasks = _symbols .Select(sym => sym.Symbol.CreateSwatchAsync(24, 24, 96.0, Colors.Transparent)) .ToArray(); symbolCombo.ItemsSource = new List <ImageSource>(await Task.WhenAll(swatchTasks)); } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
// Note: all code below (except call to ConfigureOfflineJobForBasemap) is identical to code in the Generate offline map sample. #region Generate offline map private async void Initialize() { try { // Call a function to set up the AuthenticationManager for OAuth. SetOAuthInfo(); // Create the ArcGIS Online portal. ArcGISPortal portal = await ArcGISPortal.CreateAsync(); // Get the Naperville water web map item using its ID. PortalItem webmapItem = await PortalItem.CreateAsync(portal, WebMapId); // Create a map from the web map item. Map onlineMap = new Map(webmapItem); // Display the map in the MapView. MyMapView.Map = onlineMap; // Disable user interactions on the map (no panning or zooming from the initial extent). MyMapView.InteractionOptions = new MapViewInteractionOptions { IsEnabled = false }; // Create a graphics overlay for the extent graphic and apply a renderer. SimpleLineSymbol aoiOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Red, 3); GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(aoiOutlineSymbol) }; MyMapView.GraphicsOverlays.Add(extentOverlay); // Add a graphic to show the area of interest (extent) that will be taken offline. Graphic aoiGraphic = new Graphic(_areaOfInterest); extentOverlay.Graphics.Add(aoiGraphic); // Hide the map loading progress indicator. LoadingIndicator.Visibility = Windows.UI.Xaml.Visibility.Collapsed; // When the map view unloads, try to clean up existing output data folders. MyMapView.Unloaded += (s, e) => { // Find output mobile map folders in the temp directory. string[] outputFolders = Directory.GetDirectories(Environment.ExpandEnvironmentVariables("%TEMP%"), "NapervilleWaterNetwork*"); // Loop through the folder names and delete them. foreach (string dir in outputFolders) { try { // Delete the folder. Directory.Delete(dir, true); } catch (Exception) { // Ignore exceptions (files might be locked, for example). } } }; } catch (Exception ex) { MessageDialog dialog = new MessageDialog(ex.ToString(), "Error loading map"); await dialog.ShowAsync(); } }
private void ApplyCurrentSettings() { Grid grid; // First, update the grid based on the type selected. switch (_selectedGridType) { case "LatLong": grid = new LatitudeLongitudeGrid(); break; case "MGRS": grid = new MgrsGrid(); break; case "UTM": grid = new UtmGrid(); break; case "USNG": default: grid = new UsngGrid(); break; } // Next, apply the label position setting. grid.LabelPosition = _selectedLabelPosition; // Next, apply the grid color and label color settings for each zoom level. for (long level = 0; level < grid.LevelCount; level++) { // Set the grid color if the grid is selected for display. if (_selectedGridColor != null) { // Set the line symbol. Symbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, _selectedGridColor.Value, 2); grid.SetLineSymbol(level, lineSymbol); } // Set the label color if labels are enabled for display. if (_selectedLabelColor != null) { // Set the text symbol. Symbol textSymbol = new TextSymbol { Color = _selectedLabelColor.Value, Size = 16, FontWeight = FontWeight.Bold }; grid.SetTextSymbol(level, textSymbol); } } // Next, hide the grid if it has been hidden. if (_selectedGridColor == null) { grid.IsVisible = false; } // Next, hide the labels if they have been hidden. if (_selectedLabelColor == null) { grid.IsLabelVisible = false; } // Apply the updated grid. _myMapView.Grid = grid; }
private async void Initialize() { // Create and add the map. MyMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard); MyMapView.PropertyChanged += async(o, e) => { // Start the location display on the mapview. try { // Permission request only needed on Android. if (e.PropertyName == nameof(MyMapView.LocationDisplay) && MyMapView.LocationDisplay != null) { #if XAMARIN_ANDROID // See implementation in MainActivity.cs in the Android platform project. bool permissionGranted = await MainActivity.Instance.AskForLocationPermission(); if (!permissionGranted) { throw new Exception("Location permission not granted."); } #endif MyMapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter; await MyMapView.LocationDisplay.DataSource.StartAsync(); MyMapView.LocationDisplay.IsEnabled = true; } } catch (Exception ex) { Debug.WriteLine(ex); await Application.Current.MainPage.DisplayAlert("Couldn't start location", ex.Message, "OK"); } }; // Enable authentication. SetOAuthInfo(); var credential = await AuthenticationManager.Current.GenerateCredentialAsync(_routingUri); AuthenticationManager.Current.AddCredential(credential); try { // Create the route task. _routeTask = await RouteTask.CreateAsync(_routingUri); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", "Failed to start sample", "OK"); Debug.WriteLine(ex.Message); } // Create route display overlay and symbology. _routeOverlay = new GraphicsOverlay(); SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Yellow, 1); _routeOverlay.Renderer = new SimpleRenderer(routeSymbol); // Create stop display overlay. _stopsOverlay = new GraphicsOverlay(); // Add the overlays to the map. MyMapView.GraphicsOverlays.Add(_routeOverlay); MyMapView.GraphicsOverlays.Add(_stopsOverlay); // Wait for the user to place stops. MyMapView.GeoViewTapped += MapView_GeoViewTapped; // Update the help text. HelpLabel.Text = "Tap to set a start point"; }
//唯一值渲染 private IUniqueValueRenderer CreateTrackUniqueValueRenderer(IFeatureClass featureClass, string fieldName) { IRgbColor color = new RgbColor(); color.Red = 0; color.Blue = 0; color.Green = 255; ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); simpleLineSymbol.Color = (IColor)color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.0; IUniqueValueRenderer uniqueRenderer = new UniqueValueRenderer(); uniqueRenderer.FieldCount = 1; uniqueRenderer.set_Field(0, fieldName); uniqueRenderer.DefaultSymbol = (ISymbol)simpleLineSymbol; uniqueRenderer.UseDefaultSymbol = true; Random rand = new Random(); bool bValFound = false; IFeatureCursor featureCursor = featureClass.Search(null, true); IFeature feature = null; string val = string.Empty; int fieldID = featureClass.FindField(fieldName); if (-1 == fieldID) { return(uniqueRenderer); } while ((feature = featureCursor.NextFeature()) != null) { bValFound = false; val = Convert.ToString(feature.get_Value(fieldID)); for (int i = 0; i < uniqueRenderer.ValueCount - 1; i++) { if (uniqueRenderer.get_Value(i) == val) { bValFound = true; } } if (!bValFound)//need to add the value to the renderer { color.Red = rand.Next(255); color.Blue = rand.Next(255); color.Green = rand.Next(255); simpleLineSymbol = new SimpleLineSymbol(); simpleLineSymbol.Color = (IColor)color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.0; uniqueRenderer.AddValue(val, "name", (ISymbol)simpleLineSymbol); } } ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(featureCursor); return(uniqueRenderer); }
// 测试用方法 private async void myTestBtn_Click(object sender, RoutedEventArgs e) { //IReadOnlyList<LegendInfo> i = await myMapView.Map.OperationalLayers[0].GetLegendInfosAsync(); //myTest.Text = "///" + i[0].Name; //若Name改变,说明图层顺序修改成功 //myTest.Text = myMapView.Map.OperationalLayers[0].Name + ""; //var window = new Window();//Windows窗体 //Controls.DrawAndEdit mytest = new Controls.DrawAndEdit(); //UserControl写的界面 //window.Content = mytest; //window.SizeToContent = SizeToContent.WidthAndHeight; //window.WindowStartupLocation = WindowStartupLocation.Manual; //window.Left = 600; //window.Top = 50; //window.Title = "1234"; //window.Show(); //List<StackPanel> mis = Utils.GetChildNode.GetChildObjects<StackPanel>(userControlsLayoutCsy); //myTest.Text = "shu: " + mis.Count(); //closeAllTools(); //userControlsLayoutCsy.Visibility = Visibility.Hidden; //myDrawAndEdit.Visibility = Visibility.Visible; // Create a new unique value renderer. FeatureLayer statesLayer = (FeatureLayer)myMapView.Map.OperationalLayers[0]; UniqueValueRenderer regionRenderer = new UniqueValueRenderer(); // Add the "SUB_REGION" field to the renderer. regionRenderer.FieldNames.Add("FID"); // Define a line symbol to use for the region fill symbols. SimpleLineSymbol stateOutlineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, System.Drawing.Color.White, 0.7); // Define distinct fill symbols for a few regions (use the same outline symbol). SimpleFillSymbol pacificFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.Blue, stateOutlineSymbol); SimpleFillSymbol mountainFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.LawnGreen, stateOutlineSymbol); SimpleFillSymbol westSouthCentralFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, System.Drawing.Color.SandyBrown, stateOutlineSymbol); // Add values to the renderer: define the label, description, symbol, and attribute value for each. regionRenderer.UniqueValues.Add( new UniqueValue("Pacific", "Pacific Region", pacificFillSymbol, 1)); regionRenderer.UniqueValues.Add( new UniqueValue("Mountain", "Rocky Mountain Region", mountainFillSymbol, 2)); regionRenderer.UniqueValues.Add( new UniqueValue("West South Central", "West South Central Region", westSouthCentralFillSymbol, 3)); // Set the default region fill symbol for regions not explicitly defined in the renderer. SimpleFillSymbol defaultFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Cross, System.Drawing.Color.Gray, null); regionRenderer.DefaultSymbol = defaultFillSymbol; regionRenderer.DefaultLabel = "Other"; // Apply the unique value renderer to the states layer. statesLayer.Renderer = regionRenderer; // Add created layer to the map. //myMapView.Map.OperationalLayers.Add(statesLayer); //// Assign the map to the MapView. //myMapView.Map = myMap; await myMapView.SetViewpointCenterAsync(new MapPoint(-10846309.950860, 4683272.219411, SpatialReferences.WebMercator), 20000000); }
private void Initialize() { // Create a spatial reference that's suitable for creating planar buffers in north central Texas (State Plane). SpatialReference statePlaneNorthCentralTexas = new SpatialReference(32038); // Define a polygon that represents the valid area of use for the spatial reference. // This information is available at https://developers.arcgis.com/net/latest/wpf/guide/pdf/projected_coordinate_systems_rt100_3_0.pdf List <MapPoint> spatialReferenceExtentCoords = new List <MapPoint> { new MapPoint(-103.070, 31.720, SpatialReferences.Wgs84), new MapPoint(-103.070, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.000, 34.580, SpatialReferences.Wgs84), new MapPoint(-94.00, 31.720, SpatialReferences.Wgs84) }; _spatialReferenceArea = new Polygon(spatialReferenceExtentCoords); _spatialReferenceArea = GeometryEngine.Project(_spatialReferenceArea, statePlaneNorthCentralTexas) as Polygon; // Create a map that uses the North Central Texas state plane spatial reference. Map bufferMap = new Map(statePlaneNorthCentralTexas); // Add some base layers (counties, cities, and highways). Uri usaLayerSource = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer"); ArcGISMapImageLayer usaLayer = new ArcGISMapImageLayer(usaLayerSource); bufferMap.Basemap.BaseLayers.Add(usaLayer); // Use a new EnvelopeBuilder to expand the spatial reference extent 120%. EnvelopeBuilder envBuilder = new EnvelopeBuilder(_spatialReferenceArea.Extent); envBuilder.Expand(1.2); // Set the map's initial extent to the expanded envelope. Envelope startingEnvelope = envBuilder.ToGeometry(); bufferMap.InitialViewpoint = new Viewpoint(startingEnvelope); // Assign the map to the MapView. MyMapView.Map = bufferMap; // Create a graphics overlay to show the buffer polygon graphics. GraphicsOverlay bufferGraphicsOverlay = new GraphicsOverlay { // Give the overlay an ID so it can be found later. Id = "buffers" }; // Create a graphic to show the spatial reference's valid extent (envelope) with a dashed red line. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 5); Graphic spatialReferenceExtentGraphic = new Graphic(_spatialReferenceArea, lineSymbol); // Add the graphic to a new overlay. GraphicsOverlay spatialReferenceGraphicsOverlay = new GraphicsOverlay(); spatialReferenceGraphicsOverlay.Graphics.Add(spatialReferenceExtentGraphic); // Add the graphics overlays to the MapView. MyMapView.GraphicsOverlays.Add(bufferGraphicsOverlay); MyMapView.GraphicsOverlays.Add(spatialReferenceGraphicsOverlay); // Wire up the MapView's GeoViewTapped event handler. MyMapView.GeoViewTapped += MyMapView_GeoViewTapped; }
private static LineSymbol cloneLineSymbol(LineSymbol lineSymbol) { if (lineSymbol == null) { return(null); } ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol mappingSimpleLineSymbol = lineSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol; if (mappingSimpleLineSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol ls = new ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol() { Color = CloneBrush(mappingSimpleLineSymbol.Color), ControlTemplate = mappingSimpleLineSymbol.ControlTemplate, SelectionColor = CloneBrush(mappingSimpleLineSymbol.SelectionColor), Width = mappingSimpleLineSymbol.Width, }; return(ls); } SimpleLineSymbol simpleLineSymbol = lineSymbol as SimpleLineSymbol; if (simpleLineSymbol != null) { SimpleLineSymbol ls = new SimpleLineSymbol() { Color = CloneBrush(simpleLineSymbol.Color), ControlTemplate = simpleLineSymbol.ControlTemplate, Style = simpleLineSymbol.Style, Width = simpleLineSymbol.Width, }; return(ls); } CartographicLineSymbol cLineSymbol = lineSymbol as CartographicLineSymbol; if (cLineSymbol != null) { CartographicLineSymbol cs = new CartographicLineSymbol() { Color = CloneBrush(cLineSymbol.Color), ControlTemplate = cLineSymbol.ControlTemplate, DashArray = cLineSymbol.DashArray, DashCap = cLineSymbol.DashCap, DashOffset = cLineSymbol.DashOffset, EndLineCap = cLineSymbol.EndLineCap, LineJoin = cLineSymbol.LineJoin, MiterLimit = cLineSymbol.MiterLimit, StartLineCap = cLineSymbol.StartLineCap, Width = cLineSymbol.Width, }; return(cs); } LineSymbol l = new LineSymbol() { Color = CloneBrush(lineSymbol.Color), ControlTemplate = lineSymbol.ControlTemplate, Width = lineSymbol.Width, }; return(l); }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. try { TileCache tileCache = new TileCache(DataManager.GetDataFolder("e4a398afe9a945f3b0f4dca1e4faccb5", "SanFrancisco.tpkx")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. myMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2); // Create a graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add the graphics overlay to the map view. myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. myMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all layers from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the URL for this layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Skip tables that aren't for point features.{ if (onlineTable.GeometryType != GeometryType.Point) { continue; } // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button now that sample is ready. myGenerateButton.IsEnabled = true; } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK"); } }
public void Work(object obj) { int type = Convert.ToInt32(obj); DrawShape drawType; _points = null; _tempTextGraphic = null; totalLength = 0; Symbol symbol = null; switch (type) { case 0: _points = new List <MapPoint>(); _tempTextGraphic = new List <Graphic>(); symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Orange; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; drawType = DrawShape.Polyline; break; case 1: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = System.Windows.Media.Colors.Orange; ((SimpleLineSymbol)symbol).Style = SimpleLineStyle.Dash; ((SimpleLineSymbol)symbol).Width = 2; drawType = DrawShape.Polygon; break; default: throw new ArgumentOutOfRangeException(); } Geometry geo; if (symbol != null) { _map.Dispatcher.Invoke( new Action( async delegate { if (_map.MapView.Editor.IsActive) { _map.MapView.Editor.Cancel.Execute(null); } try { geo = await _map.MapView.Editor.RequestShapeAsync(drawType, symbol); } catch { geo = null; IsObsolete = true; //clearTextGraphic(); Callback?.Invoke(null); return; } if (geo != null) { // create a new graphic; set the Geometry and Symbol Graphic graphic = new Graphic { Geometry = geo, Symbol = symbol }; MapPoint mp; string text; if (geo is Polyline) { mp = (geo as Polyline).Parts.Last().Last().EndPoint; text = distanceToStr(GeometryEngine.Length(geo) * 111000); } else { mp = (geo as Polygon).Parts.Last().Last().EndPoint; text = areaToStr(GeometryEngine.GeodesicArea(geo) * 111000 * 111000); } addTextSymbol(text, mp); _map.GetGraphicLayer("Drawing").Graphics.Add(graphic); IsObsolete = true; Callback?.Invoke(text); } })); } }
private async void Initialize() { try { // Create the utility network. _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServerUrl)); // Create the map. MyMapView.Map = new Map(Basemap.CreateTopographicVector()); // Get all of the edges and junctions in the network. IEnumerable <UtilityNetworkSource> edges = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Edge); IEnumerable <UtilityNetworkSource> junctions = _utilityNetwork.Definition.NetworkSources.Where(n => n.SourceType == UtilityNetworkSourceType.Junction); // Add all edges that are not subnet lines to the map. foreach (UtilityNetworkSource source in edges) { if (source.SourceUsageType != UtilityNetworkSourceUsageType.SubnetLine && source.FeatureTable != null) { MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable)); } } // Add all junctions to the map. foreach (UtilityNetworkSource source in junctions) { if (source.FeatureTable != null) { MyMapView.Map.OperationalLayers.Add(new FeatureLayer(source.FeatureTable)); } } // Create a graphics overlay for associations. _associationsOverlay = new GraphicsOverlay(); MyMapView.GraphicsOverlays.Add(_associationsOverlay); // Symbols for the associations. Symbol attachmentSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Green, 5d); Symbol connectivitySymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, Color.Red, 5d); // Create a renderer for the associations. var attachmentValue = new UniqueValue("Attachment", string.Empty, attachmentSymbol, UtilityAssociationType.Attachment.ToString()); var connectivityValue = new UniqueValue("Connectivity", string.Empty, connectivitySymbol, UtilityAssociationType.Connectivity.ToString()); _associationsOverlay.Renderer = new UniqueValueRenderer(new List <string> { "AssociationType" }, new List <UniqueValue> { attachmentValue, connectivityValue }, string.Empty, null); // Populate the legend in the UI. Dictionary <UtilityAssociationType, ImageSource> legend; legend = new Dictionary <UtilityAssociationType, ImageSource>(); RuntimeImage attachmentSwatch = await attachmentSymbol.CreateSwatchAsync(); legend[UtilityAssociationType.Attachment] = await attachmentSwatch?.ToImageSourceAsync(); RuntimeImage connectSwatch = await connectivitySymbol.CreateSwatchAsync(); legend[UtilityAssociationType.Connectivity] = await connectSwatch?.ToImageSourceAsync(); AssociationLegend.ItemsSource = legend; // Set the starting viewpoint. await MyMapView.SetViewpointAsync(InitialViewpoint); // Add the associations in the starting viewpoint. AddAssociations(); } catch (Exception ex) { await new MessageDialog(ex.Message, ex.GetType().Name).ShowAsync(); } }
// Create line / fill symbols private async Task SetupSymbolsAsync() { try { int size = Convert.ToInt32(LayoutRoot.Resources["ImageSize"]); // Create symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List<SampleSymbol>() { new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Red, Style = SimpleLineStyle.Dash, Width = 2 }), new SampleSymbol(new SimpleLineSymbol() { Color = Colors.Blue, Style = SimpleLineStyle.DashDot, Width = 4 }), new SampleSymbol(new SimpleFillSymbol() { Color = Colors.Red, Style = SimpleFillStyle.Solid }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 255, 0), Style = SimpleFillStyle.DiagonalCross, Outline = blackOutlineSymbol }), new SampleSymbol(new SimpleFillSymbol() { Color = Color.FromArgb(100, 0, 0, 255), Style = SimpleFillStyle.Vertical, Outline = blackOutlineSymbol }), new SampleSymbol(new PictureFillSymbol() { Outline = blackOutlineSymbol }, "ms-appx:///Assets/x-24x24.png"), new SampleSymbol(new PictureFillSymbol() { Outline = blackOutlineSymbol }, "http://static.arcgis.com/images/Symbols/Cartographic/esriCartographyMarker_79_Blue.png") }; // Set image sources for picture fill symbols await Task.WhenAll(_symbols.Where(s => s.Symbol is PictureFillSymbol) .Select(s => ((PictureFillSymbol)s.Symbol).SetSourceAsync(s.SymbolUri))); // Create image swatches for the UI Task<ImageSource>[] swatchTasks = _symbols .Select(sym => sym.Symbol.CreateSwatchAsync(size, size, 96.0, Colors.Transparent)) .ToArray(); symbolCombo.ItemsSource = new List<ImageSource>(await Task.WhenAll(swatchTasks)); symbolCombo.SelectedIndex = 0; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private async void BufferButton_Click(object sender, RoutedEventArgs e) { try { // Call a function to delete any existing buffer polygons so they can be recreated. ClearBufferPolygons(); // Check if the user wants to create a single unioned buffer or independent buffers around each map point. bool areBuffersUnioned = UnionCheckBox.IsChecked == true; // Iterate all point graphics and create a list of map points and buffer distances for each. List <MapPoint> bufferMapPoints = new List <MapPoint>(); List <double> bufferDistances = new List <double>(); foreach (Graphic bufferGraphic in MyMapView.GraphicsOverlays["buffers"].Graphics) { // Only use point graphics. if (bufferGraphic.Geometry.GeometryType == GeometryType.Point) { // Get the geometry (map point) from the graphic. MapPoint bufferLocation = bufferGraphic.Geometry as MapPoint; // Read the "distance" attribute to get the buffer distance entered when the point was tapped. double bufferDistanceFeet = (double)bufferGraphic.Attributes["distance"]; // Add the point and the corresponding distance to the lists. bufferMapPoints.Add(bufferLocation); bufferDistances.Add(bufferDistanceFeet); } } // Call GeometryEngine.Buffer with a list of map points and a list of buffered distances. IEnumerable <Geometry> bufferPolygons = GeometryEngine.Buffer(bufferMapPoints, bufferDistances, areBuffersUnioned); // Create the outline for the buffered polygons. SimpleLineSymbol bufferPolygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkBlue, 3); // Loop through all the geometries in the buffer results. There will be one buffered polygon if // the result geometries were unioned. Otherwise, there will be one buffer per input geometry. foreach (Geometry poly in bufferPolygons) { // Create a random color to use for buffer polygon fill. Color bufferPolygonColor = GetRandomColor(); // Create simple fill symbol for the buffered polygon using the fill color and outline. SimpleFillSymbol bufferPolygonFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, bufferPolygonColor, bufferPolygonOutlineSymbol); // Create a new graphic for the buffered polygon using the fill symbol. Graphic bufferPolygonGraphic = new Graphic(poly, bufferPolygonFillSymbol) { // Specify a z-index of 0 to ensure the polygons draw below the tap points. ZIndex = 0 }; // Add the buffered polygon graphic to the graphics overlay. MyMapView.GraphicsOverlays[0].Graphics.Add(bufferPolygonGraphic); } } catch (Exception ex) { // Display an error message if there is a problem generating the buffers. await new MessageDialog(ex.Message, "Unable to create buffer polygons").ShowAsync(); } }
private async void Initialize() { // Hook up the DrawStatusChanged event. MyMapView.DrawStatusChanged += OnDrawStatusChanged; // Construct the map and set the MapView.Map property. Map map = new Map(Basemap.CreateLightGrayCanvasVector()); MyMapView.Map = map; try { // Create a ClosestFacilityTask using the San Diego Uri. _task = await ClosestFacilityTask.CreateAsync(new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/ClosestFacility")); // List of facilities to be placed around San Diego area. _facilities = new List <Facility> { new Facility(new MapPoint(-1.3042129900625112E7, 3860127.9479775648, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042193400557665E7, 3862448.873041752, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3046882875518233E7, 3862704.9896770366, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3040539754780494E7, 3862924.5938606677, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3042571225655518E7, 3858981.773018156, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3039784633928463E7, 3856692.5980474586, SpatialReferences.WebMercator)), new Facility(new MapPoint(-1.3049023883956768E7, 3861993.789732541, SpatialReferences.WebMercator)) }; // Center the map on the San Diego facilities. Envelope fullExtent = GeometryEngine.CombineExtents(_facilities.Select(facility => facility.Geometry)); await MyMapView.SetViewpointGeometryAsync(fullExtent, 50); // Create a symbol for displaying facilities. _facilitySymbol = new PictureMarkerSymbol(new Uri("https://static.arcgis.com/images/Symbols/SafetyHealth/Hospital.png")) { Height = 30, Width = 30 }; // Incident symbol. _incidentSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, Color.FromArgb(255, 0, 0, 0), 30); // Route to hospital symbol. _routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.FromArgb(255, 0, 0, 255), 5.0f); // Create Graphics Overlays for incidents and facilities. _incidentGraphicsOverlay = new GraphicsOverlay(); _facilityGraphicsOverlay = new GraphicsOverlay(); // Create a graphic and add to graphics overlay for each facility. foreach (Facility facility in _facilities) { _facilityGraphicsOverlay.Graphics.Add(new Graphic(facility.Geometry, _facilitySymbol)); } // Add each graphics overlay to MyMapView. MyMapView.GraphicsOverlays.Add(_incidentGraphicsOverlay); MyMapView.GraphicsOverlays.Add(_facilityGraphicsOverlay); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void ShowServiceAreasButton_Click(object sender, RoutedEventArgs e) { // Finish any sketches in progress. // If the sketch editor complete command is enabled, a sketch is in progress. if (MyMapView.SketchEditor.CompleteCommand.CanExecute(null)) { // Finish the sketch. MyMapView.SketchEditor.CompleteCommand.Execute(null); DrawBarrierButton.Content = "Draw barrier"; } // Use a local variable for the graphics overlay. GraphicCollection allGraphics = MyMapView.GraphicsOverlays[0].Graphics; // Get a list of the facilities from the graphics overlay. List <ServiceAreaFacility> serviceAreaFacilities = (from g in allGraphics where (string)g.Attributes["Type"] == "Facility" select new ServiceAreaFacility((MapPoint)g.Geometry)).ToList(); // Check that there is at least 1 facility to find a service area for. if (!serviceAreaFacilities.Any()) { await new MessageDialog("Must have at least one Facility!", "Sample error").ShowAsync(); return; } // Create the service area task and parameters based on the Uri. ServiceAreaTask serviceAreaTask = await ServiceAreaTask.CreateAsync(_serviceAreaUri); // Store the default parameters for the service area in an object. ServiceAreaParameters serviceAreaParameters = await serviceAreaTask.CreateDefaultParametersAsync(); // Add impedance cutoffs for facilities (drive time minutes). serviceAreaParameters.DefaultImpedanceCutoffs.Add(2.0); serviceAreaParameters.DefaultImpedanceCutoffs.Add(5.0); // Set the level of detail for the polygons. serviceAreaParameters.PolygonDetail = ServiceAreaPolygonDetail.High; // Get a list of the barriers from the graphics overlay. List <PolylineBarrier> polylineBarriers = (from g in allGraphics where (string)g.Attributes["Type"] == "Barrier" select new PolylineBarrier((Polyline)g.Geometry)).ToList(); // Add the barriers to the service area parameters. serviceAreaParameters.SetPolylineBarriers(polylineBarriers); // Update the parameters to include all of the placed facilities. serviceAreaParameters.SetFacilities(serviceAreaFacilities); // Clear existing graphics for service areas. foreach (Graphic g in allGraphics.ToList()) { // Check if the graphic g is a service area. if ((string)g.Attributes["Type"] == "ServiceArea") { allGraphics.Remove(g); } } try { // Solve for the service area of the facilities. ServiceAreaResult result = await serviceAreaTask.SolveServiceAreaAsync(serviceAreaParameters); // Loop over each facility. for (int i = 0; i < serviceAreaFacilities.Count; i++) { // Create list of polygons from a service facility. List <ServiceAreaPolygon> polygons = result.GetResultPolygons(i).ToList(); // Symbol for the outline of the service areas. SimpleLineSymbol serviceOutline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkGray, 3.0f); // Create a list of fill symbols for the polygons. List <SimpleFillSymbol> fillSymbols = new List <SimpleFillSymbol>(); fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(70, 255, 0, 0), serviceOutline)); fillSymbols.Add(new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, System.Drawing.Color.FromArgb(70, 255, 165, 0), serviceOutline)); // Loop over every polygon in every facilities result. for (int j = 0; j < polygons.Count; j++) { // Create the graphic for the service areas, alternating between fill symbols. Graphic serviceGraphic = new Graphic(polygons[j].Geometry, new Dictionary <string, object>() { { "Type", "ServiceArea" } }, fillSymbols[j % 2]) { ZIndex = 0 }; // Add graphic for service area. Alternate the color of each polygon. allGraphics.Add(serviceGraphic); } } } catch (Esri.ArcGISRuntime.Http.ArcGISWebException exception) { if (exception.Message.ToString().Equals("Unable to complete operation.")) { await new MessageDialog("Facility not within San Diego area!", "Sample error").ShowAsync(); } else { await new MessageDialog("An ArcGIS web exception occurred. \n", "Sample error").ShowAsync(); } } }
private void windowClosed_Line(object sender, EventArgs e) { featureStyle = 2; simpleLineSymbol = SymbolFormCSY.LineCsy.simpleLineSymbol; }
// Create marker symbols private async Task SetupSymbolsAsync() { try { int size = Convert.ToInt32(LayoutRoot.Resources["ImageSize"]); int sizePt = (int)((float)size / DisplayInformation.GetForCurrentView().LogicalDpi * 72); // Create simple marker symbols var blackOutlineSymbol = new SimpleLineSymbol() { Color = Colors.Black, Style = SimpleLineStyle.Solid, Width = 1 }; _symbols = new List <MarkerSymbol>() { new SimpleMarkerSymbol() { Color = Colors.Red, Size = sizePt, Style = SimpleMarkerStyle.Circle, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Green, Size = sizePt, Style = SimpleMarkerStyle.Diamond, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Blue, Size = sizePt, Style = SimpleMarkerStyle.Square, Outline = blackOutlineSymbol }, new SimpleMarkerSymbol() { Color = Colors.Purple, Size = sizePt, Style = SimpleMarkerStyle.X, Outline = blackOutlineSymbol }, }; // Set image sources for picture marker symbols List <Task> setSourceTasks = new List <Task>(); var stickPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(stickPinSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/RedStickpin.png"))); _symbols.Add(stickPinSymbol); var pushPinSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(pushPinSymbol.SetSourceAsync(new Uri("http://static.arcgis.com/images/Symbols/Basic/RedShinyPin.png"))); _symbols.Add(pushPinSymbol); var xPictureSymbol = new PictureMarkerSymbol() { Width = size, Height = size }; setSourceTasks.Add(xPictureSymbol.SetSourceAsync(new Uri("ms-appx:///Assets/x-24x24.png"))); _symbols.Add(xPictureSymbol); await Task.WhenAll(setSourceTasks); // Create image swatches for the UI Task <ImageSource>[] swatchTasks = _symbols .Select(sym => sym.CreateSwatchAsync()) .ToArray(); symbolCombo.ItemsSource = await Task.WhenAll(swatchTasks); symbolCombo.SelectedIndex = 0; } catch (Exception ex) { Debug.WriteLine("Error: " + ex.Message); } }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk TileCache tileCache = new TileCache(await GetTpkPath()); // Create the corresponding layer based on the tile cache ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap Map myMap = new Map(sfBasemap); // Assign the map to the MapView myMapView.Map = myMap; // Create a new symbol for the extent graphic SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer GraphicsOverlay extentOverlay = new GraphicsOverlay(); extentOverlay.Renderer = new SimpleRenderer(lineSymbol); // Add graphics overlay to the map view myMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes myMapView.ViewpointChanged += MapViewExtentChanged; // Set up an event handler for 'tapped' events myMapView.GeoViewTapped += GeoViewTapped; // Update the local data path for the geodatabase file String iOSFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); _gdbPath = Path.Combine(iOSFolder, "wildfire.geodatabase"); // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } }
// Initializes the set of layers used by the operation private void initializeLayers() { 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 ocean current (results) layer SimpleLineSymbol currentSymbol = new SimpleLineSymbol() { Color = Colors.Red, Width = 3, Style = SimpleLineStyle.DashDotDot }; // ocean currents layer GraphicsLayer oceanCurrentsLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = currentSymbol} }; // Bind the ClippedCounties property to the GraphicsSource of the clipped counties layer Binding b = new Binding("Currents") { Source = this }; BindingOperations.SetBinding(oceanCurrentsLayer, GraphicsLayer.GraphicsSourceProperty, b); // Add the layer Layers.Add(oceanCurrentsLayer); // Symbol for tap points layer SimpleLineSymbol tapPointsOutline = new SimpleLineSymbol() { Color = Colors.Black }; SimpleMarkerSymbol tapPointsSymbol = new SimpleMarkerSymbol() { Color = Colors.White, Outline = tapPointsOutline }; // Tap points layer GraphicsLayer tapPointsLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = tapPointsSymbol } }; // Bind the TapPoints property to the GraphicsSource of the tap points layer b = new Binding("TapPoints") { Source = this }; BindingOperations.SetBinding(tapPointsLayer, GraphicsLayer.GraphicsSourceProperty, b); // Add the layer to the map Layers.Add(tapPointsLayer); }
private async void Initialize() { _statsVC = new StatsDisplayViewController(); // Apply appropriate maps to the scene and the inset map view. _insetMapView.Map = new Map(Basemap.CreateImagery()); _insetMapView.IsAttributionTextVisible = false; _mySceneView.Scene = new Scene(Basemap.CreateImagery()); // Apply the elevation source. Surface surface = new Surface(); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); surface.ElevationSources.Add(elevationSource); _mySceneView.Scene.BaseSurface = surface; // Create and add the graphics overlay. GraphicsOverlay sceneOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute } }; _mySceneView.GraphicsOverlays.Add(sceneOverlay); // Create a renderer to handle updating plane's orientation. SimpleRenderer renderer3D = new SimpleRenderer(); RendererSceneProperties renderProperties = renderer3D.SceneProperties; // Use expressions to keep the renderer properties updated as parameters of the rendered object. renderProperties.HeadingExpression = "[HEADING]"; renderProperties.PitchExpression = "[PITCH]"; renderProperties.RollExpression = "[ROLL]"; // Apply the renderer to the scene view's overlay. sceneOverlay.Renderer = renderer3D; // Create renderer to symbolize plane and update plane orientation in the inset map. SimpleRenderer renderer2D = new SimpleRenderer { Symbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.Blue, 10), RotationExpression = "[ANGLE]" }; // Update the inset map with a new GraphicsOverlay based on the renderer. GraphicsOverlay insetMapOverlay = new GraphicsOverlay { Renderer = renderer2D }; _insetMapView.GraphicsOverlays.Add(insetMapOverlay); // Create placeholder graphic for showing the mission route in the inset map. SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); _routeGraphic = new Graphic { Symbol = routeSymbol }; insetMapOverlay.Graphics.Add(_routeGraphic); // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above. Dictionary <string, object> plane2DAttributes = new Dictionary <string, object> { // Set the angle for the plane graphic. ["ANGLE"] = 0f }; // Create the graphic from the attributes and the initial point. _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes); // Add the plane graphic to the inset map via the overlay. insetMapOverlay.Graphics.Add(_plane2D); try { // Create the model graphic for the plane. string modelPath = DataManager.GetDataFolder("681d6f7694644709a7c830ec57a2d72b", "Bristol.dae"); // Create the scene symbol from the path to the model. ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0); // Create the graphic with an initial location and the plane symbol. _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol); // Add the plane to the overlay. sceneOverlay.Graphics.Add(_plane3D); // Create the orbit camera controller to follow the plane. _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0) { CameraPitchOffset = 75.0 }; _mySceneView.CameraController = _orbitCameraController; // Create a timer; this animates the plane. // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps). _animationTimer = new Timer(60) { AutoReset = true }; // Set the initial mission for when the sample loads. ChangeMission(_missionToItemId.Keys.First()); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Apply appropriate maps to the scene and the inset map view InsetMapView.Map = new Map(BasemapStyle.ArcGISImageryStandard); MySceneView.Scene = new Scene(BasemapStyle.ArcGISImageryStandard); // Update the mission selection UI MissionSelectionBox.ItemsSource = _missionToItemId.Keys; MissionSelectionBox.SelectedIndex = 0; // Wire up the selection change event to call the ChangeMission method; this method resets the animation and starts a new mission MissionSelectionBox.SelectionChanged += async(sender, args) => { await ChangeMission(args.AddedItems[0].ToString()); }; // Apply the elevation source Surface surface = new Surface(); ElevationSource elevationSource = new ArcGISTiledElevationSource(_elevationServiceUrl); surface.ElevationSources.Add(elevationSource); MySceneView.Scene.BaseSurface = surface; // Create and add the graphics overlay GraphicsOverlay sceneOverlay = new GraphicsOverlay { SceneProperties = { SurfacePlacement = SurfacePlacement.Absolute } }; MySceneView.GraphicsOverlays.Add(sceneOverlay); // Create a renderer to handle updating plane's orientation SimpleRenderer renderer3D = new SimpleRenderer(); RendererSceneProperties renderProperties = renderer3D.SceneProperties; // Use expressions to keep the renderer properties updated as parameters of the rendered object renderProperties.HeadingExpression = "[HEADING]"; renderProperties.PitchExpression = "[PITCH]"; renderProperties.RollExpression = "[ROLL]"; // Apply the renderer to the scene view's overlay sceneOverlay.Renderer = renderer3D; // Create renderer to symbolize plane and update plane orientation in the inset map SimpleRenderer renderer2D = new SimpleRenderer(); // Create the symbol that will be used for the plane SimpleMarkerSymbol plane2DSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Triangle, Color.Blue, 10); // Apply the symbol to the renderer renderer2D.Symbol = plane2DSymbol; // Apply a rotation expression to the renderer renderer2D.RotationExpression = "[ANGLE]"; // Update the inset map with a new GraphicsOverlay based on the renderer GraphicsOverlay insetMapOperlay = new GraphicsOverlay { Renderer = renderer2D }; InsetMapView.GraphicsOverlays.Add(insetMapOperlay); // Create placeholder graphic for showing the mission route in the inset map SimpleLineSymbol routeSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); _routeGraphic = new Graphic { Symbol = routeSymbol }; insetMapOperlay.Graphics.Add(_routeGraphic); // Create the plane graphic; this is symbolized as a blue triangle because of renderer implemented above // Create the attribute dictionary Dictionary <string, object> plane2DAttributes = new Dictionary <string, object>(); // Set the angle for the plane graphic plane2DAttributes["ANGLE"] = 0f; // Create the graphic from the attributes and the initial point _plane2D = new Graphic(new MapPoint(0, 0, SpatialReferences.Wgs84), plane2DAttributes); // Add the plane graphic to the inset map via the overlay insetMapOperlay.Graphics.Add(_plane2D); try { // Create the model graphic for the plane // Get the path to the 3D model string modelPath = GetModelPath(); // Create the scene symbol from the path to the model ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0); // Create the graphic with an initial location and the plane symbol _plane3D = new Graphic(new MapPoint(0, 0, 0, SpatialReferences.Wgs84), plane3DSymbol); // Add the plane to the overlay sceneOverlay.Graphics.Add(_plane3D); // Create the orbit camera controller to follow the plane _orbitCameraController = new OrbitGeoElementCameraController(_plane3D, 20.0) { CameraPitchOffset = 75.0 }; MySceneView.CameraController = _orbitCameraController; // Create a timer; this will enable animating the plane // The value is the duration of the timer in milliseconds. This controls the speed of the animation (fps) _animationTimer = new Timer(60) { Enabled = true, AutoReset = true }; // Move the plane every time the timer expires _animationTimer.Elapsed += AnimatePlane; // Set the initial mission for when the sample loads await ChangeMission(_missionToItemId.Keys.First()); } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; bool ready = true; if (app == null || app.Current2DMapControl == null) { return; } m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; ISimpleFillSymbol pFillSym = new SimpleFillSymbol(); pFillSym.Color = pColor; pFillSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSym.Outline = pLineSym; object symbol = pFillSym as object; IRubberBand band = new RubberPolygonClass(); IGeometry pGeo = band.TrackNew(m_Display, null); app.Current2DMapControl.DrawShape(pGeo, ref symbol); WaitForm.Start("正在查询...", "请稍后"); if (pGeo.IsEmpty) { IPoint searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); //m_ActiveView.FocusMap.SelectByShape(geo, s, false); } if (ready) { WaitForm.Start("正在准备导出,请稍后..."); IFeatureClass fc = GetUpdateRegionFC(); if (fc == null) { XtraMessageBox.Show("当前地图中没有找到\"修测范围\"图层,无法绘制修测范围!", "修测范围确定"); return; } IMap pMap = app.Current2DMapControl.Map; if (pMap == null) { WaitForm.Stop(); return; } //ISelectionEnvironment selEnv = new SelectionEnvironmentClass(); //pMap.SelectByShape(pGeo, selEnv, false); //ISelection pSelection = pMap.FeatureSelection; FolderBrowserDialog sfd = new FolderBrowserDialog(); if (sfd.ShowDialog() == DialogResult.OK) { string strRegionName = string.Format("{0}{1}点{2}分", DateTime.Now.ToLongDateString(), DateTime.Now.Hour, DateTime.Now.Minute); //存储范围线 WaitForm.SetCaption("正在存储范围线,请稍后..."); SaveFanWei(pGeo, strRegionName, fc); string strPath = String.Format(@"{0}\{1}.dxf", sfd.SelectedPath, strRegionName); if (this.m_Workspace == null) { XtraMessageBox.Show("获得数据工作空间失败"); WaitForm.Stop(); return; } WaitForm.SetCaption("开始导出数据,请稍后..."); ExportData(strPath, pGeo, pMap, this.m_Workspace); WaitForm.SetCaption("数据导出成功!"); XtraMessageBox.Show("数据导出成功!"); RestoreEnv(); //CreateFeature(pGeo, pMap, fc); } WaitForm.Stop(); } } } catch (System.Exception ex) { WaitForm.Stop(); return; } }
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 override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { DF2DApplication app = DF2DApplication.Application; bool ready = true; if (app == null || app.Current2DMapControl == null) { return; } m_ActiveView = app.Current2DMapControl.ActiveView; IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay; try { if (button == 1) { ISimpleLineSymbol pLineSym = new SimpleLineSymbol(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 255; pColor.Blue = 0; pLineSym.Color = pColor; pLineSym.Style = esriSimpleLineStyle.esriSLSSolid; pLineSym.Width = 2; ISimpleFillSymbol pFillSym = new SimpleFillSymbol(); pFillSym.Color = pColor; pFillSym.Style = esriSimpleFillStyle.esriSFSDiagonalCross; pFillSym.Outline = pLineSym; object symbol = pFillSym as object; IRubberBand band = new RubberPolygonClass(); IGeometry pGeo = band.TrackNew(m_Display, null); app.Current2DMapControl.DrawShape(pGeo, ref symbol); WaitForm.Start("正在查询...", "请稍后"); if (pGeo.IsEmpty) { IPoint searchPoint = new PointClass(); searchPoint.PutCoords(mapX, mapY); pGeo = PublicFunction.DoBuffer(searchPoint, PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate)); //m_ActiveView.FocusMap.SelectByShape(geo, s, false); } if (ready) { IMap pMap = app.Current2DMapControl.Map; ISelectionEnvironment selEnv = new SelectionEnvironmentClass(); pMap.SelectByShape(pGeo, selEnv, false); ISelection pSelection = pMap.FeatureSelection; FrmCoordConvert dialog = new FrmCoordConvert(pMap); WaitForm.Stop(); dialog.ShowDialog(); if (dialog.DialogResult == DialogResult.Cancel) { RestoreEnv(); } } } } catch (System.Exception ex) { } }
private void Initialize() { // Configure the basemap. _myMapView.Map = new Map(Basemap.CreateTopographic()); // Create the graphics overlay. _graphicsOverlay = new GraphicsOverlay(); // Add the overlay to the MapView. _myMapView.GraphicsOverlays.Add(_graphicsOverlay); // Update the selection color. _myMapView.SelectionProperties.Color = Color.Yellow; // Create the point collection that defines the polygon. PointCollection polygonPoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-5991501.677830, 5599295.131468), new MapPoint(-6928550.398185, 2087936.739807), new MapPoint(-3149463.800709, 1840803.011362), new MapPoint(-1563689.043184, 3714900.452072), new MapPoint(-3180355.516764, 5619889.608838) }; // Create the polygon. Polygon polygonGeometry = new Polygon(polygonPoints); // Define the symbology of the polygon. SimpleLineSymbol polygonOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.Green, 2); SimpleFillSymbol polygonFillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, System.Drawing.Color.Green, polygonOutlineSymbol); // Create the polygon graphic and add it to the graphics overlay. _polygonGraphic = new Graphic(polygonGeometry, polygonFillSymbol); _graphicsOverlay.Graphics.Add(_polygonGraphic); // Create the point collection that defines the polyline. PointCollection polylinePoints = new PointCollection(SpatialReferences.WebMercator) { new MapPoint(-4354240.726880, -609939.795721), new MapPoint(-3427489.245210, 2139422.933233), new MapPoint(-2109442.693501, 4301843.057130), new MapPoint(-1810822.771630, 7205664.366363) }; // Create the polyline. Polyline polylineGeometry = new Polyline(polylinePoints); // Create the polyline graphic and add it to the graphics overlay. _polylineGraphic = new Graphic(polylineGeometry, new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Red, 4)); _graphicsOverlay.Graphics.Add(_polylineGraphic); // Create the point geometry that defines the point graphic. MapPoint pointGeometry = new MapPoint(-4487263.495911, 3699176.480377, SpatialReferences.WebMercator); // Define the symbology for the point. SimpleMarkerSymbol locationMarker = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10); // Create the point graphic and add it to the graphics overlay. _pointGraphic = new Graphic(pointGeometry, locationMarker); _graphicsOverlay.Graphics.Add(_pointGraphic); // Listen for taps; the spatial relationships will be updated in the handler. _myMapView.GeoViewTapped += MyMapView_GeoViewTapped; // Set the viewpoint to center on the point. _myMapView.SetViewpointCenterAsync(pointGeometry, 200000000); }
/// <summary> /// Initializes tool with map control. /// </summary> /// <param name="mapControl"></param> public void Initialize(MapControl mapControl) { _mapControl = mapControl; _cursor = Cursors.Cross; SimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol() { Color=new SolidColorBrush(Colors.Red), Width=2 }; _polylineDrawObject = new Draw(mapControl.map); _polylineDrawObject.LineSymbol = simpleLineSymbol; _polylineDrawObject.DrawComplete += _PolylineDrawComplete; _polylineDrawObject.DrawMode = DrawMode.Polyline; }
private static void FixSymbology(IFeatureLayer featureLayer) { //Color var geoLayer = featureLayer as IGeoFeatureLayer; if (geoLayer == null) return; var renderer = geoLayer.Renderer as ISimpleRenderer; if (renderer == null) return; var symbol = renderer.Symbol as IFillSymbol; if (symbol == null) return; //The objects at symbol.Color and symbol.Outline are immutable while the properties are not. //The objects don't complain if you try and change them, it just has no effect. //symbol.Color.NullColor = true; // appears to work but has no effect. IRgbColor nullColor = new RgbColorClass(); nullColor.NullColor = true; symbol.Color = nullColor; ILineSymbol outline = new SimpleLineSymbol(); outline.Width = 1.0; IRgbColor color = new RgbColorClass(); color.Red = 255; color.UseWindowsDithering = true; outline.Color = color; symbol.Outline = outline; //Labeling IAnnotateLayerProperties annotationProperties; IElementCollection unused; geoLayer.AnnotationProperties.QueryItem(0, out annotationProperties, out unused, out unused); ((ILabelEngineLayerProperties)annotationProperties).Expression = "[Cell_Label]"; geoLayer.DisplayAnnotation = true; }
private async void Initialize() { try { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache _tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer _tileLayer = new ArcGISTiledLayer(_tileCache); // Create the basemap based on the tile cache. Basemap _sfBasemap = new Basemap(_tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(_sfBasemap); // Assign the map to the MapView. MyMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create a graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. MyMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all layers from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Create the ServiceFeatureTable for this particular layer. ServiceFeatureTable onlineTable = new ServiceFeatureTable(new Uri(_featureServiceUri + "/" + layer.Id)); // Wait for the table to load. await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the extent graphic so that it is valid before user interaction. UpdateMapExtent(); // Enable the generate button now that the sample is ready. MyGenerateButton.IsEnabled = true; } catch (Exception ex) { ShowStatusMessage(ex.ToString()); } }
private async void QuerySublayers_Click(object sender, RoutedEventArgs e) { // Clear selected features from the graphics overlay. _selectedFeaturesOverlay.Graphics.Clear(); // If the population value entered is not numeric, warn the user and exit. double populationNumber = 0.0; if (!double.TryParse(PopulationTextBox.Text.Trim(), out populationNumber)) { MessageDialog dialog = new MessageDialog("The population value must be numeric.", "Query error"); await dialog.ShowAsync(); return; } // Get the USA map image layer (the first and only operational layer in the map). ArcGISMapImageLayer usaMapImageLayer = MyMapView.Map.OperationalLayers[0] as ArcGISMapImageLayer; // Use a utility method on the map image layer to load all the sublayers and tables. await usaMapImageLayer.LoadTablesAndLayersAsync(); // Get the sublayers of interest (skip 'Highways' since it doesn't have the POP2000 field). ArcGISMapImageSublayer citiesSublayer = usaMapImageLayer.Sublayers[0] as ArcGISMapImageSublayer; ArcGISMapImageSublayer statesSublayer = usaMapImageLayer.Sublayers[2] as ArcGISMapImageSublayer; ArcGISMapImageSublayer countiesSublayer = usaMapImageLayer.Sublayers[3] as ArcGISMapImageSublayer; // Get the service feature table for each of the sublayers. ServiceFeatureTable citiesTable = citiesSublayer.Table; ServiceFeatureTable statesTable = statesSublayer.Table; ServiceFeatureTable countiesTable = countiesSublayer.Table; // Create the query parameters that will find features in the current extent with a population greater than the value entered. QueryParameters populationQuery = new QueryParameters { WhereClause = "POP2000 > " + PopulationTextBox.Text, Geometry = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry }; // Query each of the sublayers with the query parameters. FeatureQueryResult citiesQueryResult = await citiesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult statesQueryResult = await statesTable.QueryFeaturesAsync(populationQuery); FeatureQueryResult countiesQueryResult = await countiesTable.QueryFeaturesAsync(populationQuery); // Display the selected cities in the graphics overlay. SimpleMarkerSymbol citySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 16); foreach (Feature city in citiesQueryResult) { Graphic cityGraphic = new Graphic(city.Geometry, citySymbol); _selectedFeaturesOverlay.Graphics.Add(cityGraphic); } // Display the selected counties in the graphics overlay. SimpleLineSymbol countyLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.Cyan, 2); SimpleFillSymbol countySymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, System.Drawing.Color.Cyan, countyLineSymbol); foreach (Feature county in countiesQueryResult) { Graphic countyGraphic = new Graphic(county.Geometry, countySymbol); _selectedFeaturesOverlay.Graphics.Add(countyGraphic); } // Display the selected states in the graphics overlay. SimpleLineSymbol stateLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 6); SimpleFillSymbol stateSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, System.Drawing.Color.Cyan, stateLineSymbol); foreach (Feature state in statesQueryResult) { Graphic stateGraphic = new Graphic(state.Geometry, stateSymbol); _selectedFeaturesOverlay.Graphics.Add(stateGraphic); } }
private void SolveServiceArea_Completed(object sender, RouteEventArgs e) { GraphicsLayer routeLayer = MyMap.Layers["MyServiceAreasGraphicsLayer"] as GraphicsLayer; routeLayer.Graphics.Clear(); if (e.ServiceAreaPolygons != null) { foreach (Graphic g in e.ServiceAreaPolygons) { SimpleFillSymbol symbol = new SimpleFillSymbol() { Fill = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))), BorderBrush = new SolidColorBrush(Colors.Transparent), BorderThickness = 1 }; g.Symbol = symbol; routeLayer.Graphics.Add(g); } } if (e.ServiceAreaPolylines != null) { foreach (Graphic g in e.ServiceAreaPolylines) { SimpleLineSymbol symbol = new SimpleLineSymbol() { Color = new SolidColorBrush(Color.FromArgb(100, (byte)random.Next(0, 255), (byte)random.Next(0, 255), (byte)random.Next(0, 255))), Width = 1, }; g.Symbol = symbol; routeLayer.Graphics.Add(g); } } }
private async void Initialize() { // Create a new map using the WebMercator spatial reference. Map newMap = new Map(SpatialReferences.WebMercator) { // Set the basemap of the map to be a topographic layer. Basemap = Basemap.CreateTopographic() }; // Assign the map to the MapView. _myMapView.Map = newMap; // Create a graphics overlay to hold the input geometries for the clip operation. _inputGeometriesGraphicsOverlay = new GraphicsOverlay(); // Add the input geometries graphics overlay to the MapView. _myMapView.GraphicsOverlays.Add(_inputGeometriesGraphicsOverlay); // Create a graphics overlay to hold the resulting geometries from the three GeometryEngine.Clip operations. _clipAreasGraphicsOverlay = new GraphicsOverlay(); // Add the resulting geometries graphics overlay to the MapView. _myMapView.GraphicsOverlays.Add(_clipAreasGraphicsOverlay); // Create a simple line symbol for the 1st parameter of the GeometryEngine.Clip operation - it follows the // boundary of Colorado. SimpleLineSymbol coloradoSimpleLineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Solid, System.Drawing.Color.Blue, 4); // Create the color that will be used as the fill for the Colorado graphic. It will be a semi-transparent, blue color. System.Drawing.Color coloradoFillColor = System.Drawing.Color.FromArgb(34, 0, 0, 255); // Create the simple fill symbol for the Colorado graphic - comprised of a fill style, fill color and outline. SimpleFillSymbol coloradoSimpleFillSymbol = new SimpleFillSymbol( SimpleFillSymbolStyle.Solid, coloradoFillColor, coloradoSimpleLineSymbol); // Create the geometry of the Colorado graphic. Envelope colorado = new Envelope( new MapPoint(-11362327.128340, 5012861.290274, SpatialReferences.WebMercator), new MapPoint(-12138232.018408, 4441198.773776, SpatialReferences.WebMercator)); // Create the graphic for Colorado - comprised of a polygon shape and fill symbol. _coloradoGraphic = new Graphic(colorado, coloradoSimpleFillSymbol); // Add the Colorado graphic to the input geometries graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_coloradoGraphic); // Create a simple line symbol for the three different clip geometries. SimpleLineSymbol clipGeomtriesSimpleLineSymbol = new SimpleLineSymbol( SimpleLineSymbolStyle.Dot, System.Drawing.Color.Red, 5); // Create an envelope outside Colorado. Envelope outsideEnvelope = new Envelope( new MapPoint(-11858344.321294, 5147942.225174, SpatialReferences.WebMercator), new MapPoint(-12201990.219681, 5297071.577304, SpatialReferences.WebMercator)); // Create the graphic for an envelope outside Colorado - comprised of a polyline shape and line symbol. _outsideGraphic = new Graphic(outsideEnvelope, clipGeomtriesSimpleLineSymbol); // Add the envelope outside Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_outsideGraphic); // Create an envelope intersecting Colorado. Envelope intersectingEnvelope = new Envelope( new MapPoint(-11962086.479298, 4566553.881363, SpatialReferences.WebMercator), new MapPoint(-12260345.183558, 4332053.378376, SpatialReferences.WebMercator)); // Create the graphic for an envelope intersecting Colorado - comprised of a polyline shape and line symbol. _intersectingGraphic = new Graphic(intersectingEnvelope, clipGeomtriesSimpleLineSymbol); // Add the envelope intersecting Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_intersectingGraphic); // Create a envelope inside Colorado. Envelope containedEnvelope = new Envelope( new MapPoint(-11655182.595204, 4741618.772994, SpatialReferences.WebMercator), new MapPoint(-11431488.567009, 4593570.068343, SpatialReferences.WebMercator)); // Create the graphic for an envelope inside Colorado - comprised of a polyline shape and line symbol. _containedGraphic = new Graphic(containedEnvelope, clipGeomtriesSimpleLineSymbol); // Add the envelope inside Colorado graphic to the graphics overlay collection. _inputGeometriesGraphicsOverlay.Graphics.Add(_containedGraphic); // Get the extent of all of the graphics in the graphics overlay with a little padding to used as the initial zoom extent of the map. Geometry visibleExtent = GetExtentOfGraphicsOverlay(_inputGeometriesGraphicsOverlay, 1.3, SpatialReferences.WebMercator); // Set the initial visual extent of the map view to the extent of the graphics overlay. await _myMapView.SetViewpointGeometryAsync(visibleExtent); }
private Esri.ArcGISRuntime.Symbology.Symbol GetPolylineSymbol(SurfacePlacement mode) { SimpleLineSymbol sls = new SimpleLineSymbol() { Style = SimpleLineStyle.Solid, Color = mode == SurfacePlacement.Absolute ? Colors.Red : mode == SurfacePlacement.Draped ? Colors.Yellow : Colors.LightBlue, Width = 4 }; return sls; }
private byte[] getLayerCountByType(System.Collections.Specialized.NameValueCollection boundVariables, ESRI.ArcGIS.SOESupport.JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { IMapImage mapImage = null; bool?shouldAdd = null; operationInput.TryGetAsBoolean("addlayer", out shouldAdd); if (shouldAdd.HasValue) { if ((bool)shouldAdd) { if (((IMapServerInfo4)mapServerInfo).SupportsDynamicLayers) { IRgbColor color = new RgbColor() { Blue = 255 }; ISimpleLineSymbol outline = new SimpleLineSymbol() { Color = color, Width = 1, Style = esriSimpleLineStyle.esriSLSSolid }; ISimpleFillSymbol sfs = new SimpleFillSymbol() { Color = color, Outline = outline, Style = esriSimpleFillStyle.esriSFSSolid }; ISimpleRenderer sr = new SimpleRenderer() { Symbol = (ISymbol)sfs }; IFeatureLayerDrawingDescription featureLayerDrawingDesc = new FeatureLayerDrawingDescription() { FeatureRenderer = (IFeatureRenderer)sr }; IMapServerSourceDescription mapServerSourceDesc = new TableDataSourceDescriptionClass(); ((IDataSourceDescription)mapServerSourceDesc).WorkspaceID = "MyFGDB"; ((ITableDataSourceDescription)mapServerSourceDesc).TableName = "B"; IDynamicLayerDescription dynamicLayerDesc = new LayerDescriptionClass() { ID = 3, Visible = true, DrawingDescription = (ILayerDrawingDescription)featureLayerDrawingDesc, Source = mapServerSourceDesc }; mapDesc.HonorLayerReordering = true; mapDesc.LayerDescriptions.Insert(0, (ILayerDescription)dynamicLayerDesc); mapImage = exportMap(); } } else { mapImage = exportMap(); } } responseProperties = null; JSONObject json = new JSONObject(); json.AddString("URL", mapImage.URL); return(Encoding.UTF8.GetBytes(json.ToJSONString(null))); }
//private void rdMeasureType_Click(object sender, RoutedEventArgs e) //{ // // Click Handler for Actions Radio Buttons // string content = (e.OriginalSource as RadioButton).Content.ToString(); // if (content.Equals("Line", StringComparison.InvariantCultureIgnoreCase) == true) // { // grLength.Height = new GridLength(20); // grWidth.Height = new GridLength(0); // grHeight.Height = new GridLength(0); // } // else // { // grLength.Height = new GridLength(0); // grWidth.Height = new GridLength(20); // grHeight.Height = new GridLength(20); // } //} //private void btnMeasureApply_Click(object sender, RoutedEventArgs e) //{ // this._isDrawingMeasured = true; //} #endregion #region Privates for Symbology private Symbol ChooseSymbol(string geoType, bool isMeasured = false) { try { Symbol symbol = null; ColorObj cObj; if (isMeasured == false) { cObj = (ColorObj)cboColor.SelectedItem; } else { cObj = (ColorObj)cboColor_M.SelectedItem; } ColorObj cFill; if (isMeasured == false) { cFill = (ColorObj)cboFill.SelectedItem; } else { cFill = (ColorObj)cboFill_M.SelectedItem; } int width = 1; if (isMeasured == false) { width = int.Parse(cboWidth.Items[cboWidth.SelectedIndex].ToString()); } else { width = int.Parse(cboWidth_M.Items[cboWidth_M.SelectedIndex].ToString()); } switch (geoType) { case "Point": case "MapPoint": case "MultiPoint": if (_isDrawingText == false) { symbol = new SimpleMarkerSymbol() { Size = int.Parse(cboSize.Items[cboSize.SelectedIndex].ToString()), Color = new System.Windows.Media.SolidColorBrush(cObj.cColor), Style = SimpleMarkerSymbol.SimpleMarkerStyle.Circle }; } else { symbol = new TextSymbol() { FontSize = int.Parse(cboSize.Items[cboSize.SelectedIndex].ToString()), Foreground = new System.Windows.Media.SolidColorBrush(cObj.cColor), Text = txtString.Text }; } break; case "Polyline": symbol = new SimpleLineSymbol() { Width = width, Color = new System.Windows.Media.SolidColorBrush(cObj.cColor), Style = SimpleLineSymbol.LineStyle.Solid }; break; case "Polygon": symbol = new SimpleFillSymbol() { BorderBrush = new System.Windows.Media.SolidColorBrush(cObj.cColor), BorderThickness = width, Fill = new System.Windows.Media.SolidColorBrush(cFill.cColor) }; break; } return(symbol); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.StackTrace); return(null); } }
// Initializes the set of layers used by the operation private void initializeLayers() { 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 clipped counties (results) layer SimpleLineSymbol countiesOutline = new SimpleLineSymbol() { Color = Colors.Blue }; SimpleFillSymbol countiesSymbol = new SimpleFillSymbol() { Color = Color.FromArgb(127, 200, 200, 255), Outline = countiesOutline }; // Clipped counties layer GraphicsLayer clippedCountiesLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = countiesSymbol } }; // Bind the ClippedCounties property to the GraphicsSource of the clipped counties layer Binding b = new Binding("ClippedCounties") { Source = this }; BindingOperations.SetBinding(clippedCountiesLayer, GraphicsLayer.GraphicsSourceProperty, b); // Add the layer Layers.Add(clippedCountiesLayer); // Symbol for clip lines layer SimpleLineSymbol clipLineSymbol = new SimpleLineSymbol() { Color = Colors.Red, Width = 2 }; // Clip lines layer m_clipLinesLayer = new GraphicsLayer() { Renderer = new SimpleRenderer() { Symbol = clipLineSymbol } }; // Bind the ClipLines property to the GraphicsSource of the clip lines layer b = new Binding("ClipLines") { Source = this }; BindingOperations.SetBinding(m_clipLinesLayer, GraphicsLayer.GraphicsSourceProperty, b); // Add the layer Layers.Add(m_clipLinesLayer); }