diff --git a/components/map/layers/marker.md b/components/map/layers/marker.md index e38882c5fa..299ac741bc 100644 --- a/components/map/layers/marker.md +++ b/components/map/layers/marker.md @@ -317,3 +317,7 @@ The `MapLayerMarkerSettingsTooltip` tag allows you to fine-tune the content, app } } ```` + +## See Also + +* [How to Change Map Marker Colors](slug://map-kb-change-marker-colors) diff --git a/knowledge-base/map-change-marker-colors.md b/knowledge-base/map-change-marker-colors.md new file mode 100644 index 0000000000..74acfd60cc --- /dev/null +++ b/knowledge-base/map-change-marker-colors.md @@ -0,0 +1,124 @@ +--- +title: How to Change Map Markers Colors +description: Learn how to customize the appearance of map markers by setting and changing their colors in a Blazor application. +type: how-to +page_title: How to Change Map Markers Colors +slug: map-kb-change-marker-colors +tags: map, markers +res_type: kb +ticketid: 1675518 +--- + +## Environment + + + + + + + + +
ProductMap for Blazor
+ +## Description + +When integrating a [Map for Blazor](slug://components/map/layers), you might want to customize the appearance of your map markers to differentiate them or match your application's theme. This knowledge base article also answers the following questions: + +- How can I set the color of a map marker in Blazor? +- How to change the color of specific map markers based on their titles? +- How to apply custom styles to map markers in a Blazor application? + +## Solution + +To customize the color of map markers in a Blazor application, you can [override the default theme styles](slug://themes-override). + +### Change the Color to All Map Markers + +To change the color for all markers use the following CSS approach: + +
+````RAZOR + + + + + +```` + +### Customize Specific Markers + +To change the color of specific markers, target them based on their titles using CSS. Check the runnable example below: + +````RAZOR + + + + + + + + + + + + + +@code { + private string[] Subdomains { get; set; } = new string[] { "a", "b", "c" }; + private string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"; + private string Attribution { get; set; } = "© OpenStreetMap contributors"; + private double[] Center { get; set; } = new double[] { 30.268107, -97.744821 }; + + private List MarkerData { get; set; } = new List() + { + new MarkerModel() + { + LatLng = new double[] { 30.268107, -97.744821 }, + Title = "Austin, TX", + Color = "#008000" + }, + new MarkerModel() + { + LatLng = new double[] { 37.7749, -122.4194 }, + Title = "San Francisco, CA", + Color = "#0000FF" + } + }; + + public class MarkerModel + { + public double[]? LatLng { get; set; } + public string Title { get; set; } = null!; + public string Color { get; set; } = null!; + } +} +```` + +## See Also + +- [Override Theme Styles](slug://themes-override) +- [Map - Marker Layer](slug://components/map/layers/marker)