diff --git a/src/MAUI/Maui.Samples/Converters/ColorConverter.cs b/src/MAUI/Maui.Samples/Converters/ColorConverter.cs index 57338acc7c..9125f83e6e 100644 --- a/src/MAUI/Maui.Samples/Converters/ColorConverter.cs +++ b/src/MAUI/Maui.Samples/Converters/ColorConverter.cs @@ -7,8 +7,28 @@ internal class ColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (value == null || value.GetType() != typeof(string)) { return null; } - return Microsoft.Maui.Graphics.Color.FromArgb((string)value); + if (value == null) return null; + + // Determine the object type. + Type type = value.GetType(); + + if (type == typeof(string)) + { + string colorString = value as string; + + // Color needs to be in hex format or else it will throw. + return Color.FromArgb(colorString); + } + else if (type == typeof(System.Drawing.Color)) + { + var color = (System.Drawing.Color)value; + + return new Color(color.R, color.G, color.B, color.A); + } + else + { + return null; + } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml b/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml deleted file mode 100644 index 3fb1d3a88d..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs b/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs deleted file mode 100644 index 9396fd21c9..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2022 Esri. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific -// language governing permissions and limitations under the License. - -using Esri.ArcGISRuntime.Geometry; -using Esri.ArcGISRuntime.Mapping; -using Esri.ArcGISRuntime.Symbology; -using Esri.ArcGISRuntime.UI; -using System.Reflection; - -namespace ArcGIS.Samples.RenderPictureMarkers -{ - [ArcGIS.Samples.Shared.Attributes.Sample( - name: "Picture marker symbol", - category: "Symbology", - description: "Use pictures for markers.", - instructions: "When launched, this sample displays a map with picture marker symbols. Pan and zoom to explore the map.", - tags: new[] { "graphics", "marker", "picture", "symbol", "visualization" })] - [ArcGIS.Samples.Shared.Attributes.EmbeddedResource(@"PictureMarkerSymbols\pin_star_blue.png")] - public partial class RenderPictureMarkers : ContentPage - { - public RenderPictureMarkers() - { - InitializeComponent(); - - // Create the UI, setup the control references and execute initialization - _ = Initialize(); - } - - private async Task Initialize() - { - // Create new Map with basemap - Map myMap = new Map(BasemapStyle.ArcGISTopographic); - - // Create and set initial map area - Envelope initialLocation = new Envelope( - -229835, 6550763, -222560, 6552021, - SpatialReferences.WebMercator); - myMap.InitialViewpoint = new Viewpoint(initialLocation); - - // Assign the map to the MapView - MyMapView.Map = myMap; - - // Create overlay to where graphics are shown - GraphicsOverlay overlay = new GraphicsOverlay(); - - // Add created overlay to the MapView - MyMapView.GraphicsOverlays.Add(overlay); - - // Add graphics using different source types - CreatePictureMarkerSymbolFromUrl(overlay); - try - { - await CreatePictureMarkerSymbolFromResources(overlay); - } - catch (Exception e) - { - await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); - } - } - - private void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) - { - // Create uri to the used image - Uri symbolUri = new Uri( - "https://static.arcgis.com/images/Symbols/OutdoorRecreation/Camping.png"); - - // Create new symbol using asynchronous factory method from uri. - PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri) - { - Width = 40, - Height = 40 - }; - - // Create location for the campsite - MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); - - // Create graphic with the location and symbol - Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); - - // Add graphic to the graphics overlay - overlay.Graphics.Add(campsiteGraphic); - } - - private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) - { - // Get current assembly that contains the image - Assembly currentAssembly = Assembly.GetExecutingAssembly(); - - // Get image as a stream from the resources - // Picture is defined as EmbeddedResource and DoNotCopy - Stream resourceStream = currentAssembly.GetManifestResourceStream( - "ArcGIS.Resources.PictureMarkerSymbols.pin_star_blue.png"); - - // Create new symbol using asynchronous factory method from stream - PictureMarkerSymbol pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); - pinSymbol.Height = 50; - pinSymbol.Width = 50; - - // Create location for the pint - MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); - - // Create graphic with the location and symbol - Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); - - // Add graphic to the graphics overlay - overlay.Graphics.Add(pinGraphic); - } - } -} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.md b/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.md deleted file mode 100644 index 1a7f7fb7cf..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# Picture marker symbol - -Use pictures for markers. - -![Image of picture marker symbol](renderpicturemarkers.jpg) - -## Use case - -When marking geoelements on a map, using custom, unique symbols can be helpful for highlighting and differentiating between locations. For example, a tourism office may use pictures of landmarks as symbols on an online map or app, to help prospective visitors to orient themselves more easily around a city. - -## How to use the sample - -When launched, this sample displays a map with picture marker symbols. Pan and zoom to explore the map. - -## How it works - -1. Create a `PictureMarkerSymbol` using the URI to an online or local image or a JavaFX Image (platform dependent). -2. Create a `Graphic` and set its symbol to the picture marker symbol. - -## Relevant API - -* PictureMarkerSymbol - -## About the data - -The picture marker symbols in this sample are all constructed from different types of resources: - -* [Campsite symbol constructed from a URL](https://static.arcgis.com/images/Symbols/OutdoorRecreation/Camping.png) -* Blue pin with a star stored in the resource folder that comes with the application - -## Tags - -graphics, marker, picture, symbol, visualization diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.metadata.json b/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.metadata.json deleted file mode 100644 index 390f6af017..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/readme.metadata.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "category": "Symbology", - "description": "Use pictures for markers.", - "formal_name": "RenderPictureMarkers", - "ignore": false, - "images": [ - "renderpicturemarkers.jpg" - ], - "keywords": [ - "graphics", - "marker", - "picture", - "symbol", - "visualization" - ], - "offline_data": [], - "redirect_from": [ - "/net/latest/maui/sample-code/picture-marker-symbol.htm" - ], - "relevant_apis": [ - "PictureMarkerSymbol" - ], - "snippets": [ - "RenderPictureMarkers.xaml.cs", - "RenderPictureMarkers.xaml" - ], - "title": "Picture marker symbol" -} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/renderpicturemarkers.jpg b/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/renderpicturemarkers.jpg deleted file mode 100644 index 3e960c9bb1..0000000000 Binary files a/src/MAUI/Maui.Samples/Samples/Symbology/RenderPictureMarkers/renderpicturemarkers.jpg and /dev/null differ diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml b/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml deleted file mode 100644 index a15c8eb496..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs b/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs deleted file mode 100644 index ca838e7cf6..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2022 Esri. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific -// language governing permissions and limitations under the License. - -using Esri.ArcGISRuntime.Geometry; -using Esri.ArcGISRuntime.Mapping; -using Esri.ArcGISRuntime.Symbology; -using Esri.ArcGISRuntime.UI; - -using Colors = System.Drawing.Color; - -namespace ArcGIS.Samples.RenderSimpleMarkers -{ - [ArcGIS.Samples.Shared.Attributes.Sample( - name: "Simple marker symbol", - category: "Symbology", - description: "Show a simple marker symbol on a map.", - instructions: "The sample loads with a predefined simple marker symbol, set as a red circle.", - tags: new[] { "symbol" })] - public partial class RenderSimpleMarkers : ContentPage - { - public RenderSimpleMarkers() - { - InitializeComponent(); - - // Create the UI, setup the control references and execute initialization - Initialize(); - } - - private void Initialize() - { - // Create new Map with basemap - Map myMap = new Map(BasemapStyle.ArcGISImageryStandard); - - // Create initial map location and reuse the location for graphic - MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); - Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500); - - // Set initial viewpoint - myMap.InitialViewpoint = initialViewpoint; - - // Provide used Map to the MapView - MyMapView.Map = myMap; - - // Create overlay to where graphics are shown - GraphicsOverlay overlay = new GraphicsOverlay(); - - // Add created overlay to the MapView - MyMapView.GraphicsOverlays.Add(overlay); - - // Create a simple marker symbol - SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol() - { - Color = Colors.Red, - Size = 10, - Style = SimpleMarkerSymbolStyle.Circle - }; - - // Add a new graphic with a central point that was created earlier - Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol); - overlay.Graphics.Add(graphicWithSymbol); - } - } -} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.md b/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.md deleted file mode 100644 index f7c509c126..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# Simple marker symbol - -Show a simple marker symbol on a map. - -![Image of simple marker symbol](rendersimplemarkers.jpg) - -## Use case - -Customize the appearance of a point suitable for the data. For example, a point on the map styled with a circle could represent a drilled borehole location, whereas a cross could represent the location of an old coal mine shaft. - -## How to use the sample - -The sample loads with a predefined simple marker symbol, set as a red circle. - -## How it works - -1. Create a `SimpleMarkerSymbol(SimpleMarkerSymbol.Style, color, size)`. -2. Create a `Graphic` passing in a `Point` and the simple marker symbol as parameters. -3. Add the graphic to the graphics overlay with `graphicsOverlay.Graphics.Add(graphic)`. - -## Relevant API - -* Graphic -* GraphicsOverlay -* Point -* SimpleMarkerSymbol - -## Tags - -symbol diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json b/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json deleted file mode 100644 index edb64519c5..0000000000 --- a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "category": "Symbology", - "description": "Show a simple marker symbol on a map.", - "formal_name": "RenderSimpleMarkers", - "ignore": false, - "images": [ - "rendersimplemarkers.jpg" - ], - "keywords": [ - "symbol" - ], - "offline_data": [], - "redirect_from": [ - "/net/latest/maui/sample-code/simple-marker-symbol.htm" - ], - "relevant_apis": [ - "Graphic", - "GraphicsOverlay", - "Point", - "SimpleMarkerSymbol" - ], - "snippets": [ - "RenderSimpleMarkers.xaml.cs", - "RenderSimpleMarkers.xaml" - ], - "title": "Simple marker symbol" -} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/rendersimplemarkers.jpg b/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/rendersimplemarkers.jpg deleted file mode 100644 index 7d9e3dd8d5..0000000000 Binary files a/src/MAUI/Maui.Samples/Samples/Symbology/RenderSimpleMarkers/rendersimplemarkers.jpg and /dev/null differ diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml new file mode 100644 index 0000000000..b2fee8f305 --- /dev/null +++ b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml.cs b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml.cs new file mode 100644 index 0000000000..d9a4cafb78 --- /dev/null +++ b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml.cs @@ -0,0 +1,320 @@ +// Copyright 2024 Esri. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific +// language governing permissions and limitations under the License. + +using Esri.ArcGISRuntime.Geometry; +using Esri.ArcGISRuntime.Mapping; +using Esri.ArcGISRuntime.Symbology; +using Esri.ArcGISRuntime.UI; +using System.Reflection; +using Color = System.Drawing.Color; +using Grid = Microsoft.Maui.Controls.Grid; + +namespace ArcGIS.Samples.StyleGeometryTypesWithSymbols +{ + [ArcGIS.Samples.Shared.Attributes.Sample( + name: "Style geometry types with symbols", + category: "Symbology", + description: "Use a symbol to display a geometry on a map.", + instructions: "Tap \"Edit Styles\" and select a geometry to edit with the picker. Use the controls to change the symbol properties for the geometry.", + tags: new[] { "display", "fill", "graphics", "line", "marker", "overlay", "picture", "point", "symbol", "visualization" })] + [ArcGIS.Samples.Shared.Attributes.OfflineData()] + public partial class StyleGeometryTypesWithSymbols + { + // Item sources for the pickers. + public List SimpleMarkerSymbolStyles => Enum.GetValues(typeof(SimpleMarkerSymbolStyle)).Cast().ToList(); + public List SimpleLineSymbolStyles => Enum.GetValues(typeof(SimpleLineSymbolStyle)).Cast().ToList(); + public List SimpleFillSymbolStyles => Enum.GetValues(typeof(SimpleFillSymbolStyle)).Cast().ToList(); + + // Hold the selected graphic. + private Graphic _selectedGraphic; + + // Flag indicating if styling should be applied to a polygon's fill or outline. + private bool _stylingPolygonFill = true; + + public StyleGeometryTypesWithSymbols() + { + InitializeComponent(); + _ = Initialize(); + } + + private async Task Initialize() + { + // Create a new map with a topographic basemap initially centered on Woolgarston, England. + MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic) + { + InitialViewpoint = new Viewpoint(new MapPoint(-225e3, 6_553e3, SpatialReferences.WebMercator), 88e3) + }; + + // A graphics overlay for displaying the geometry graphics on the map view. + var graphicsOverlay = new GraphicsOverlay(); + + // Create the simple marker symbol for styling the point. + var pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Purple, 12); + + // Create simple line symbol for styling the polyline. + var polylineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Red, 6); + + // Create the simple fill symbol for styling the polygon, including its outline. + var polygonSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.ForwardDiagonal, Color.Blue, + new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Green, 3)); + + // Create a point graphic and add it to the graphics overlay. + var point = new MapPoint(-225e3, 6_560e3, SpatialReferences.WebMercator); + var pointGraphic = new Graphic(point, pointSymbol); + graphicsOverlay.Graphics.Add(pointGraphic); + + // Create a polyline graphic and add it to the graphics overlay. + var points = new MapPoint[2] + { + new MapPoint(-223e3, 6_559e3, SpatialReferences.WebMercator), + new MapPoint(-227e3, 6_559e3, SpatialReferences.WebMercator) + }; + var polyline = new Polyline(points, SpatialReferences.WebMercator); + var polylineGraphic = new Graphic(polyline, polylineSymbol); + graphicsOverlay.Graphics.Add(polylineGraphic); + + // Create a polygon graphic and add it to the graphics overlay. + points = new MapPoint[4] + { + new MapPoint(-222e3, 6_558e3, SpatialReferences.WebMercator), + new MapPoint(-228e3, 6_558e3, SpatialReferences.WebMercator), + new MapPoint(-228e3, 6_555e3, SpatialReferences.WebMercator), + new MapPoint(-222e3, 6_555e3, SpatialReferences.WebMercator) + }; + var polygon = new Polygon(points, SpatialReferences.WebMercator); + var polygonGraphic = new Graphic(polygon, polygonSymbol); + graphicsOverlay.Graphics.Add(polygonGraphic); + + // Create a graphic with a picture marker symbol (image resource) and add it to the graphics overlay. + var pinGraphic = await MakePictureMarkerSymbolFromImage(new MapPoint(-226_770, 6_550_470, SpatialReferences.WebMercator)); + graphicsOverlay.Graphics.Add(pinGraphic); + + // Create a graphic with a picture marker symbol (URL) and add it to the graphics overlay. + var imageUri = new Uri("https://static.arcgis.com/images/Symbols/OutdoorRecreation/Camping.png"); + var campsiteSymbol = new PictureMarkerSymbol(imageUri) + { + Width = 25, + Height = 25 + }; + var campsitePoint = new MapPoint(-223_560, 6_552_020, SpatialReferences.WebMercator); + var campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); + graphicsOverlay.Graphics.Add(campsiteGraphic); + + // Add the graphics overlay to the map view. + MyMapView.GraphicsOverlays.Add(graphicsOverlay); + + // Setup bindings for the UI controls. + PointSizeStepper.BindingContext = PointGrid.BindingContext = graphicsOverlay.Graphics[0]; + PolylineWidthStepper.BindingContext = PolylineGrid.BindingContext = graphicsOverlay.Graphics[1]; + PolygonOutlineWidthStepper.BindingContext = PolygonGrid.BindingContext = graphicsOverlay.Graphics[2]; + + // Populate the color collection views with colors. + var colors = new List() + { + Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Purple + }; + PointColorCollectionView.ItemsSource = PolylineColorCollectionView.ItemsSource = + PolygonFillColorCollectionView.ItemsSource = PolygonOutlineColorCollectionView.ItemsSource = colors; + + // Set the style picker item sources. + PointStylePicker.ItemsSource = SimpleMarkerSymbolStyles; + PolygonOutlineStylePicker.ItemsSource = PolylineStylePicker.ItemsSource = SimpleLineSymbolStyles; + PolygonFillStylePicker.ItemsSource = SimpleFillSymbolStyles; + + // Check the point radio button by default. + PointRadioButton.IsChecked = true; + + // Set the selected styles to reflect the initial symbology. + PointStylePicker.SelectedItem = SimpleMarkerSymbolStyle.Circle; + PolylineStylePicker.SelectedItem = SimpleLineSymbolStyle.Dash; + PolygonFillStylePicker.SelectedItem = SimpleFillSymbolStyle.ForwardDiagonal; + PolygonOutlineStylePicker.SelectedItem = SimpleLineSymbolStyle.Solid; + + // Set the selected colors to reflect the initial symbology. + PointColorCollectionView.SelectedItem = Color.Purple; + PolylineColorCollectionView.SelectedItem = Color.Red; + PolygonFillColorCollectionView.SelectedItem = Color.Blue; + PolygonOutlineColorCollectionView.SelectedItem = Color.Green; + + // Subscribe to events for updating the UI now that initialization is complete. + PointStylePicker.SelectedIndexChanged += StylePicker_SelectionChanged; + PolylineStylePicker.SelectedIndexChanged += StylePicker_SelectionChanged; + PolygonFillStylePicker.SelectedIndexChanged += PolygonFillStylePicker_SelectionChanged; + PolygonOutlineStylePicker.SelectedIndexChanged += PolygonOutlineStylePicker_SelectionChanged; + PointColorCollectionView.SelectionChanged += ColorCollectionView_SelectionChanged; + PolylineColorCollectionView.SelectionChanged += ColorCollectionView_SelectionChanged; + PolygonFillColorCollectionView.SelectionChanged += PolygonFillColorCollectionView_SelectionChanged; + PolygonOutlineColorCollectionView.SelectionChanged += PolygonOutlineColorCollectionView_SelectionChanged; + } + + private async Task MakePictureMarkerSymbolFromImage(MapPoint point) + { + // Hold a reference to the picture marker symbol. + PictureMarkerSymbol pinSymbol; + + // Get current assembly that contains the image. + Assembly currentAssembly = Assembly.GetExecutingAssembly(); + + // Get the resource name of the blue pin star image + string resourceStreamName = this.GetType().Assembly.GetManifestResourceNames().Single(str => str.EndsWith("pin_star_blue.png")); + + // Load the resource stream + using (Stream resourceStream = this.GetType().Assembly.GetManifestResourceStream(resourceStreamName)) + { + // Create new symbol using asynchronous factory method from stream. + pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); + pinSymbol.Width = 60; + pinSymbol.Height = 60; + // The image is a pin; offset the image so that the pinpoint is on the point rather than the image's true center. + pinSymbol.LeaderOffsetX = 30; + pinSymbol.OffsetY = 14; + } + + return new Graphic(point, pinSymbol); + } + + #region UI event handlers + + private void GeometryTypeRadioButton_CheckedChanged(object sender, CheckedChangedEventArgs e) + { + // Get the selected radio button. + var radioButton = sender as RadioButton; + + // Get the binding context of the radio button. + var grid = radioButton.BindingContext as Grid; + + // Collapse all grids. + PointGrid.IsVisible = PolylineGrid.IsVisible = PolygonGrid.IsVisible = false; + + // Show the selected grid. + grid.IsVisible = true; + + // Set the selected graphic based on the grid's binding context. + _selectedGraphic = grid.BindingContext as Graphic; + } + + private void StylePicker_SelectionChanged(object sender, EventArgs e) + { + // Get the selected picker item. + var picker = sender as Picker; + + // Update the symbol style based on the selected picker item. + switch (_selectedGraphic.Geometry.GeometryType) + { + case GeometryType.Point: + ((SimpleMarkerSymbol)_selectedGraphic.Symbol).Style = (SimpleMarkerSymbolStyle)picker.SelectedItem; + break; + + case GeometryType.Polyline: + ((SimpleLineSymbol)_selectedGraphic.Symbol).Style = (SimpleLineSymbolStyle)picker.SelectedItem; + break; + + case GeometryType.Polygon: + var symbol = (SimpleFillSymbol)_selectedGraphic.Symbol; + if (_stylingPolygonFill) + { + symbol.Style = (SimpleFillSymbolStyle)picker.SelectedItem; + } + else + { + symbol.Outline = new SimpleLineSymbol((SimpleLineSymbolStyle)picker.SelectedItem, symbol.Outline.Color, symbol.Outline.Width); + } + break; + } + } + + private void ColorCollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // Selected graphic will be null when initializing the UI. + if (_selectedGraphic == null) return; + + // Get the selected item. + var color = (Color)((CollectionView)sender).SelectedItem; + + // Update the symbol color based on the selected geometry type. + switch (_selectedGraphic.Geometry.GeometryType) + { + case GeometryType.Point: + ((SimpleMarkerSymbol)_selectedGraphic.Symbol).Color = color; + break; + + case GeometryType.Polyline: + ((SimpleLineSymbol)_selectedGraphic.Symbol).Color = color; + break; + + case GeometryType.Polygon: + var symbol = (SimpleFillSymbol)_selectedGraphic.Symbol; + if (_stylingPolygonFill) + { + symbol.Color = color; + } + else + { + symbol.Outline.Color = color; + } + break; + } + } + + private void SizeStepper_ValueChanged(object sender, ValueChangedEventArgs e) + { + // Selected graphic will be null when initializing the UI. + if (_selectedGraphic == null) return; + + // Update the symbol size based on the sender's binding context. + switch (_selectedGraphic.Geometry.GeometryType) + { + case GeometryType.Point: + ((SimpleMarkerSymbol)_selectedGraphic.Symbol).Size = e.NewValue; + PointSizeLabel.Text = $"Size: {e.NewValue}"; + break; + + case GeometryType.Polyline: + ((SimpleLineSymbol)_selectedGraphic.Symbol).Width = e.NewValue; + PolylineWidthLabel.Text = $"Width: {e.NewValue}"; + break; + + case GeometryType.Polygon: + ((SimpleFillSymbol)_selectedGraphic.Symbol).Outline.Width = e.NewValue; + PolygonOutlineWidthLabel.Text = $"Width: {e.NewValue}"; + break; + } + } + + #region Polygon styling + + private void PolygonFillStylePicker_SelectionChanged(object sender, EventArgs e) + { + _stylingPolygonFill = true; + StylePicker_SelectionChanged(sender, e); + } + + private void PolygonOutlineStylePicker_SelectionChanged(object sender, EventArgs e) + { + _stylingPolygonFill = false; + StylePicker_SelectionChanged(sender, e); + } + + private void PolygonFillColorCollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + _stylingPolygonFill = true; + ColorCollectionView_SelectionChanged(sender, e); + } + + private void PolygonOutlineColorCollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + _stylingPolygonFill = false; + ColorCollectionView_SelectionChanged(sender, e); + } + + #endregion Polygon styling + + #endregion UI event handlers + } +} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.md b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.md new file mode 100644 index 0000000000..75ea09a8d2 --- /dev/null +++ b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.md @@ -0,0 +1,39 @@ +# Style geometry types with symbols + +Use a symbol to display a geometry on a map. + +![Screenshot of Style geometry types with symbols sample](stylegeometrytypeswithsymbols.jpg) + +## Use case + +Customize the appearance of a geometry type with a symbol style suitable for the data. For example, a tourism office may use pictures of landmarks as symbols on an online map or app to help prospective visitors orient themselves more easily around a city. A point on the map styled with a circle could represent a drilled borehole location, whereas a cross could represent the location of an old coal mine shaft. A red line with a dashed style could represent a geological fault mapped on a geological map. A polygon with a brown 'forward-diagonal' fill style could represent an area of artificial ground mapped on a geological map. + +## How to use the sample + +Tap "Edit Styles" and select a geometry to edit with the picker. Use the controls to change the symbol properties for the geometry. + +## How it works + +1. Create a `PictureMarkerSymbol` or `SimpleMarkerSymbol` to style a `Point`. + * For the picture marker symbol, create it using a URL or image and set its height property. + * For the simple marker symbol, set the `Style`, `Color`, and `Size` properties. +2. Create a `SimpleLineSymbol` to style a `Polyline`. + * Set the `Style`, `Color`, and `Size` properties. +3. Create a `SimpleFillSymbol` to style a `Polygon`. + * Set the `Style`, `Color`, and `Outline` properties. +4. Create `Graphic`s using the geometries and symbols and add them to a `GraphicsOverlay`. +5. Add the graphics overlay to a `MapView`. + +## Relevant API + +* Geometry +* Graphic +* GraphicsOverlay +* PictureMarkerSymbol +* SimpleFillSymbol +* SimpleLineSymbol +* SimpleMarkerSymbol + +## Tags + +display, fill, graphics, line, marker, overlay, picture, point, symbol, visualization diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.metadata.json b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.metadata.json new file mode 100644 index 0000000000..c451011f89 --- /dev/null +++ b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/readme.metadata.json @@ -0,0 +1,41 @@ +{ + "category": "Symbology", + "description": "Use a symbol to display a geometry on a map.", + "formal_name": "StyleGeometryTypesWithSymbols", + "ignore": false, + "images": [ + "stylegeometrytypeswithsymbols.jpg" + ], + "keywords": [ + "display", + "fill", + "graphics", + "line", + "marker", + "overlay", + "picture", + "point", + "symbol", + "visualization" + ], + "offline_data": [], + "redirect_from": [ + "/net/latest/maui/sample-code/picture-marker-symbol.htm", + "/net/latest/maui/sample-code/style-geometry-types-with-symbols.htm", + "/net/latest/maui/sample-code/simple-marker-symbol.htm" + ], + "relevant_apis": [ + "Geometry", + "Graphic", + "GraphicsOverlay", + "PictureMarkerSymbol", + "SimpleFillSymbol", + "SimpleLineSymbol", + "SimpleMarkerSymbol" + ], + "snippets": [ + "StyleGeometryTypesWithSymbols.xaml.cs", + "StyleGeometryTypesWithSymbols.xaml" + ], + "title": "Style geometry types with symbols" +} \ No newline at end of file diff --git a/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/stylegeometrytypeswithsymbols.jpg b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/stylegeometrytypeswithsymbols.jpg new file mode 100644 index 0000000000..9c3ae331cc Binary files /dev/null and b/src/MAUI/Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols/stylegeometrytypeswithsymbols.jpg differ diff --git a/src/MAUI/readme.md b/src/MAUI/readme.md index 5db79742a6..6dedcef0bc 100644 --- a/src/MAUI/readme.md +++ b/src/MAUI/readme.md @@ -250,12 +250,11 @@ * [Custom dictionary style](Maui.Samples/Samples/Symbology/CustomDictionaryStyle) - Use a custom dictionary created from a web style or style file (.stylx) to symbolize features using a variety of attribute values. * [Distance composite scene symbol](Maui.Samples/Samples/Symbology/UseDistanceCompositeSym) - Change a graphic's symbol based on the camera's proximity to it. * [Feature layer extrusion](Maui.Samples/Samples/Symbology/FeatureLayerExtrusion) - Extrude features based on their attributes. -* [Picture marker symbol](Maui.Samples/Samples/Symbology/RenderPictureMarkers) - Use pictures for markers. * [Read symbols from mobile style](Maui.Samples/Samples/Symbology/SymbolsFromMobileStyle) - Combine multiple symbols from a mobile style file into a single symbol. * [Render multilayer symbols](Maui.Samples/Samples/Symbology/RenderMultilayerSymbols) - Show different kinds of multilayer symbols on a map similar to some pre-defined 2D simple symbol styles. * [Scene symbols](Maui.Samples/Samples/Symbology/SceneSymbols) - Show various kinds of 3D symbols in a scene. -* [Simple marker symbol](Maui.Samples/Samples/Symbology/RenderSimpleMarkers) - Show a simple marker symbol on a map. * [Simple renderer](Maui.Samples/Samples/Symbology/SimpleRenderers) - Display common symbols for all graphics in a graphics overlay with a renderer. +* [Style geometry types with symbols](Maui.Samples/Samples/Symbology/StyleGeometryTypesWithSymbols) - Use a symbol to display a geometry on a map. * [Unique value renderer](Maui.Samples/Samples/Symbology/RenderUniqueValues) - Render features in a layer using a distinct symbol for each unique attribute value. ## Utility network diff --git a/src/Samples.Shared/Resources/FeaturedSamples.xml b/src/Samples.Shared/Resources/FeaturedSamples.xml index d0a4c6186e..8c2fd5fe5e 100644 --- a/src/Samples.Shared/Resources/FeaturedSamples.xml +++ b/src/Samples.Shared/Resources/FeaturedSamples.xml @@ -32,6 +32,9 @@ FilterFeaturesInScene ShowLabelsOnLayer3D + + StyleGeometryTypesWithSymbols + CreateLoadReport ValidateUtilityNetworkTopology diff --git a/src/WPF/WPF.Viewer/Converters/ColorToSolidBrushConverter.cs b/src/WPF/WPF.Viewer/Converters/ColorToSolidBrushConverter.cs index 992390607c..b5a5879e37 100644 --- a/src/WPF/WPF.Viewer/Converters/ColorToSolidBrushConverter.cs +++ b/src/WPF/WPF.Viewer/Converters/ColorToSolidBrushConverter.cs @@ -13,17 +13,28 @@ public object Convert(object value, Type targetType, object parameter, System.Gl // Get the input value as a System.Drawing.Color. Color inColor = (Color)value; + // Create a solid color brush using the color and return it. + return Convert(inColor); + } + + public static WinMedia.SolidColorBrush Convert(Color color) + { // Convert the input System.Drawing.Color to a System.Windows.Media.Color. - WinMedia.Color outColor = WinMedia.Color.FromArgb(inColor.A, inColor.R, inColor.G, inColor.B); + WinMedia.Color outColor = WinMedia.Color.FromArgb(color.A, color.R, color.G, color.B); // Create a solid color brush using the color and return it. - WinMedia.SolidColorBrush brush = new WinMedia.SolidColorBrush(outColor); - return brush; + return new WinMedia.SolidColorBrush(outColor); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } + + public static Color ConvertBack(WinMedia.SolidColorBrush brush) + { + // Convert the input System.Windows.Media.Color to a System.Drawing.Color. + return Color.FromArgb(brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B); + } } } diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.jpg b/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.jpg deleted file mode 100644 index d479ac4ddc..0000000000 Binary files a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.jpg and /dev/null differ diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml b/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml deleted file mode 100644 index 3dec710d27..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs b/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs deleted file mode 100644 index 86442ae7bc..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/RenderPictureMarkers.xaml.cs +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2016 Esri. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific -// language governing permissions and limitations under the License. - -using Esri.ArcGISRuntime.Geometry; -using Esri.ArcGISRuntime.Mapping; -using Esri.ArcGISRuntime.Symbology; -using Esri.ArcGISRuntime.UI; -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using System.Windows; - -namespace ArcGIS.WPF.Samples.RenderPictureMarkers -{ - [ArcGIS.Samples.Shared.Attributes.Sample( - name: "Picture marker symbol", - category: "Symbology", - description: "Use pictures for markers.", - instructions: "When launched, this sample displays a map with picture marker symbols. Pan and zoom to explore the map.", - tags: new[] { "graphics", "marker", "picture", "symbol", "visualization" })] - [ArcGIS.Samples.Shared.Attributes.EmbeddedResource(@"PictureMarkerSymbols\pin_star_blue.png")] - public partial class RenderPictureMarkers - { - public RenderPictureMarkers() - { - InitializeComponent(); - - // Create the UI, setup the control references and execute initialization - _ = Initialize(); - } - - private async Task Initialize() - { - // Create new Map with basemap - Map myMap = new Map(BasemapStyle.ArcGISTopographic); - - // Create and set initial map area - Envelope initialLocation = new Envelope( - -229835, 6550763, -222560, 6552021, - SpatialReferences.WebMercator); - myMap.InitialViewpoint = new Viewpoint(initialLocation); - - // Assign the map to the MapView - MyMapView.Map = myMap; - - // Create overlay to where graphics are shown - GraphicsOverlay overlay = new GraphicsOverlay(); - - // Add created overlay to the MapView - MyMapView.GraphicsOverlays.Add(overlay); - - // Add graphics using different source types - CreatePictureMarkerSymbolFromUrl(overlay); - try - { - await CreatePictureMarkerSymbolFromResources(overlay); - } - catch (Exception e) - { - MessageBox.Show(e.ToString(), "Error"); - } - } - - private void CreatePictureMarkerSymbolFromUrl(GraphicsOverlay overlay) - { - // Create uri to the used image - Uri symbolUri = new Uri( - "https://static.arcgis.com/images/Symbols/OutdoorRecreation/Camping.png"); - - // Create new symbol using asynchronous factory method from uri. - PictureMarkerSymbol campsiteSymbol = new PictureMarkerSymbol(symbolUri) - { - Width = 40, - Height = 40 - }; - - // Create location for the campsite - MapPoint campsitePoint = new MapPoint(-223560, 6552021, SpatialReferences.WebMercator); - - // Create graphic with the location and symbol - Graphic campsiteGraphic = new Graphic(campsitePoint, campsiteSymbol); - - // Add graphic to the graphics overlay - overlay.Graphics.Add(campsiteGraphic); - } - - private async Task CreatePictureMarkerSymbolFromResources(GraphicsOverlay overlay) - { - // Hold a reference to the picture marker symbol - PictureMarkerSymbol pinSymbol; - - // Get current assembly that contains the image - Assembly currentAssembly = Assembly.GetExecutingAssembly(); - - // Get the resource name of the blue pin image - string resourceStreamName = this.GetType().Assembly.GetManifestResourceNames().Single(str => str.EndsWith("pin_star_blue.png")); - - // Load the blue pin resource stream - using (Stream resourceStream = this.GetType().Assembly. - GetManifestResourceStream(resourceStreamName)) - { - // Create new symbol using asynchronous factory method from stream - pinSymbol = await PictureMarkerSymbol.CreateAsync(resourceStream); - pinSymbol.Width = 50; - pinSymbol.Height = 50; - } - - // Create location for the pint - MapPoint pinPoint = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); - - // Create graphic with the location and symbol - Graphic pinGraphic = new Graphic(pinPoint, pinSymbol); - - // Add graphic to the graphics overlay - overlay.Graphics.Add(pinGraphic); - } - } -} \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.md b/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.md deleted file mode 100644 index a4e5d72558..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# Picture marker symbol - -Use pictures for markers. - -![Image of picture marker symbol](RenderPictureMarkers.jpg) - -## Use case - -When marking geoelements on a map, using custom, unique symbols can be helpful for highlighting and differentiating between locations. For example, a tourism office may use pictures of landmarks as symbols on an online map or app, to help prospective visitors to orient themselves more easily around a city. - -## How to use the sample - -When launched, this sample displays a map with picture marker symbols. Pan and zoom to explore the map. - -## How it works - -1. Create a `PictureMarkerSymbol` using the URI to an online or local image or a JavaFX Image (platform dependent). -2. Create a `Graphic` and set its symbol to the picture marker symbol. - -## Relevant API - -* PictureMarkerSymbol - -## About the data - -The picture marker symbols in this sample are all constructed from different types of resources: - -* [Campsite symbol constructed from a URL](https://static.arcgis.com/images/Symbols/OutdoorRecreation/Camping.png) -* Blue pin with a star stored in the resource folder that comes with the application - -## Tags - -graphics, marker, picture, symbol, visualization diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.metadata.json b/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.metadata.json deleted file mode 100644 index 60cbd7b224..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderPictureMarkers/readme.metadata.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "category": "Symbology", - "description": "Use pictures for markers.", - "formal_name": "RenderPictureMarkers", - "ignore": false, - "images": [ - "RenderPictureMarkers.jpg" - ], - "keywords": [ - "graphics", - "marker", - "picture", - "symbol", - "visualization" - ], - "offline_data": [], - "redirect_from": [ - "/net/latest/wpf/sample-code/picture-marker-symbol.htm" - ], - "relevant_apis": [ - "PictureMarkerSymbol" - ], - "snippets": [ - "RenderPictureMarkers.xaml.cs", - "RenderPictureMarkers.xaml" - ], - "title": "Picture marker symbol" -} \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.jpg b/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.jpg deleted file mode 100644 index 5a6e6ed497..0000000000 Binary files a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.jpg and /dev/null differ diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml b/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml deleted file mode 100644 index a378bbc4a8..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs b/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs deleted file mode 100644 index ae8a4cea82..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/RenderSimpleMarkers.xaml.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 Esri. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific -// language governing permissions and limitations under the License. - -using Esri.ArcGISRuntime.Geometry; -using Esri.ArcGISRuntime.Mapping; -using Esri.ArcGISRuntime.Symbology; -using Esri.ArcGISRuntime.UI; - -namespace ArcGIS.WPF.Samples.RenderSimpleMarkers -{ - [ArcGIS.Samples.Shared.Attributes.Sample( - name: "Simple marker symbol", - category: "Symbology", - description: "Show a simple marker symbol on a map.", - instructions: "The sample loads with a predefined simple marker symbol, set as a red circle.", - tags: new[] { "symbol" })] - public partial class RenderSimpleMarkers - { - public RenderSimpleMarkers() - { - InitializeComponent(); - - // Create the UI, setup the control references and execute initialization - Initialize(); - } - - private void Initialize() - { - // Create new Map with basemap - Map myMap = new Map(BasemapStyle.ArcGISImageryStandard); - - // Create initial map location and reuse the location for graphic - MapPoint centralLocation = new MapPoint(-226773, 6550477, SpatialReferences.WebMercator); - Viewpoint initialViewpoint = new Viewpoint(centralLocation, 7500); - - // Set initial viewpoint - myMap.InitialViewpoint = initialViewpoint; - - // Provide used Map to the MapView - MyMapView.Map = myMap; - - // Create overlay to where graphics are shown - GraphicsOverlay overlay = new GraphicsOverlay(); - - // Add created overlay to the MapView - MyMapView.GraphicsOverlays.Add(overlay); - - // Create a simple marker symbol - SimpleMarkerSymbol simpleSymbol = new SimpleMarkerSymbol() - { - Color = System.Drawing.Color.Red, - Size = 10, - Style = SimpleMarkerSymbolStyle.Circle - }; - - // Add a new graphic with a central point that was created earlier - Graphic graphicWithSymbol = new Graphic(centralLocation, simpleSymbol); - overlay.Graphics.Add(graphicWithSymbol); - } - } -} \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.md b/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.md deleted file mode 100644 index b5a0b236bc..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# Simple marker symbol - -Show a simple marker symbol on a map. - -![Image of simple marker symbol](RenderSimpleMarkers.jpg) - -## Use case - -Customize the appearance of a point suitable for the data. For example, a point on the map styled with a circle could represent a drilled borehole location, whereas a cross could represent the location of an old coal mine shaft. - -## How to use the sample - -The sample loads with a predefined simple marker symbol, set as a red circle. - -## How it works - -1. Create a `SimpleMarkerSymbol(SimpleMarkerSymbol.Style, color, size)`. -2. Create a `Graphic` passing in a `Point` and the simple marker symbol as parameters. -3. Add the graphic to the graphics overlay with `graphicsOverlay.Graphics.Add(graphic)`. - -## Relevant API - -* Graphic -* GraphicsOverlay -* Point -* SimpleMarkerSymbol - -## Tags - -symbol diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json b/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json deleted file mode 100644 index c41bfd359c..0000000000 --- a/src/WPF/WPF.Viewer/Samples/Symbology/RenderSimpleMarkers/readme.metadata.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "category": "Symbology", - "description": "Show a simple marker symbol on a map.", - "formal_name": "RenderSimpleMarkers", - "ignore": false, - "images": [ - "RenderSimpleMarkers.jpg" - ], - "keywords": [ - "symbol" - ], - "offline_data": [], - "redirect_from": [ - "/net/latest/wpf/sample-code/simple-marker-symbol.htm" - ], - "relevant_apis": [ - "Graphic", - "GraphicsOverlay", - "Point", - "SimpleMarkerSymbol" - ], - "snippets": [ - "RenderSimpleMarkers.xaml.cs", - "RenderSimpleMarkers.xaml" - ], - "title": "Simple marker symbol" -} \ No newline at end of file diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.jpg b/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.jpg new file mode 100644 index 0000000000..6542553b9b Binary files /dev/null and b/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.jpg differ diff --git a/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml b/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml new file mode 100644 index 0000000000..fd149a1e6a --- /dev/null +++ b/src/WPF/WPF.Viewer/Samples/Symbology/StyleGeometryTypesWithSymbols/StyleGeometryTypesWithSymbols.xaml @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + +