11---
2- title : How to Customize Map Marker Colors
2+ title : How to Change Map Markers Colors
33description : Learn how to customize the appearance of map markers by setting and changing their colors in a Blazor application.
44type : how-to
5- page_title : How to Customize Map Marker Colors
6- slug : map-kb-customize -marker-colors
5+ page_title : How to Change Map Markers Colors
6+ slug : map-kb-change -marker-colors
77tags : map, markers
88res_type : kb
99ticketid : 1675518
@@ -75,12 +75,17 @@ To change the color of specific markers, target them based on their titles using
7575</TelerikMap>
7676
7777<style>
78- .my-map .k-marker[title="San Francisco, CA"] {
79- color: blue;
78+ /* targets the default state */
79+ .my-map .k-marker[title="@MarkerData1[0].Title"],
80+ /* targets the hover state */
81+ .my-map .k-marker[data-title="@MarkerData1[0].Title"] {
82+ color: @MarkerData1[0].Color;
8083 }
81-
82- .my-map .k-marker[title="Austin, TX"] {
83- color: green;
84+ /* targets the default state */
85+ .my-map .k-marker[title="@MarkerData2[0].Title"],
86+ /* targets the hover state */
87+ .my-map .k-marker[data-title="@MarkerData2[0].Title"] {
88+ color: @MarkerData2[0].Color;
8489 }
8590</style>
8691
@@ -95,7 +100,8 @@ To change the color of specific markers, target them based on their titles using
95100 new MarkerModel()
96101 {
97102 LatLng = new double[] { 30.268107, -97.744821 },
98- Title = "Austin, TX"
103+ Title = "Austin, TX",
104+ Color = "#008000"
99105 }
100106 };
101107
@@ -104,14 +110,16 @@ To change the color of specific markers, target them based on their titles using
104110 new MarkerModel()
105111 {
106112 LatLng = new double[] { 37.7749, -122.4194 },
107- Title = "San Francisco, CA"
113+ Title = "San Francisco, CA",
114+ Color = "#0000FF"
108115 }
109116 };
110117
111118 public class MarkerModel
112119 {
113- public double[] LatLng { get; set; }
120+ public double[]? LatLng { get; set; }
114121 public string Title { get; set; } = null!;
122+ public string Color { get; set; } = null!;
115123 }
116124}
117125````
0 commit comments