|
1 | 1 | ---
|
2 | 2 | title: Marker
|
3 | 3 | page_title: Map Layers - Marker
|
4 |
| -description: Discover the Blazor Map Marker Layer and explore the examples. |
| 4 | +description: Learn more about the Marker layer of the Telerik UI for Blazor Map component and explore the available examples. |
5 | 5 | slug: components/map/layers/marker
|
6 |
| -tags: telerik,blazor,map,layers,marker |
| 6 | +tags: telerikui, blazor, map, layers, marker |
7 | 7 | published: True
|
8 | 8 | position: 5
|
9 | 9 | ---
|
10 | 10 |
|
11 | 11 | # Marker Layer
|
12 | 12 |
|
13 |
| -The marker functionality allows you to add points in the map. These points are defined by geographical position in the map and can show useful information to the user in a tooltip. |
| 13 | +The marker functionality allows you to add points to the Map. These points are defined by the geographical position in the map and can show useful information to the user in a tooltip. |
14 | 14 |
|
15 |
| -**To configure a Map Layer of type Marker:** |
| 15 | +Sections in this article: |
16 | 16 |
|
17 |
| -1. Add the `TelerikMap` tag. |
| 17 | +* [Creating the Marker layer](#creating-the-marker-map-layer) |
| 18 | +* [Customizing the Marker appearance](#customizing-the-marker-appearance) |
| 19 | +* [Defining the Marker shapes](#defining-the-marker-shapes) |
| 20 | +* [Setting the Marker tooltip](#setting-the-marker-tooltip) |
| 21 | + |
| 22 | +## Creating the Marker Map Layer |
| 23 | + |
| 24 | +To configure a Map layer of the Marker type: |
| 25 | + |
| 26 | +1. Add the `TelerikMap` tag to the Map. |
18 | 27 | 2. Set the `Type` parameter of the `MapLayer` to `Marker`.
|
19 | 28 | 3. Set the `Data` parameter.
|
20 | 29 | 4. Set the `LocationField` and `TitleField` parameters.
|
21 |
| -5. Optionally, provide [Tooltip Settings](#marker-tooltip-settings) and choose [Marker Shape](#marker-shapes). |
| 30 | +5. (Optional) Provide the [tooltip settings](#marker-tooltip-settings) and choose the [Marker shape](#marker-shapes). |
22 | 31 |
|
23 |
| -The following example demonstrates how to configure the Map Marker Layer. |
| 32 | +The following example demonstrates how to configure the Marker layer of the Map. |
24 | 33 |
|
25 |
| ->caption The Map Marker Layer configuration. |
| 34 | +>caption The Marker Map layer configuration. |
26 | 35 |
|
27 | 36 | ````CSHTML
|
28 |
| -@* This code snippet showcases an example of a Marker Layer configuration. *@ |
| 37 | +@* This code snippet showcases an example of a Marker layer configuration. *@ |
29 | 38 |
|
30 | 39 | <TelerikMap Center="@Center" Zoom="3">
|
31 | 40 | <MapLayers>
|
@@ -81,22 +90,98 @@ The following example demonstrates how to configure the Map Marker Layer.
|
81 | 90 | }
|
82 | 91 | ````
|
83 | 92 |
|
84 |
| ->caption The result from the above code snippet. |
| 93 | +## Customizing the Marker Appearance |
| 94 | + |
| 95 | +To customize the marker appearance, set the string `Template` parameter in the corresponding `MapLayerMarkerSettings` inner tag of the marker. |
| 96 | + |
| 97 | +The general syntax of the Marker template is based on the [Kendo UI templates](https://docs.telerik.com/kendo-ui/framework/templates/overview). |
| 98 | + |
| 99 | +>caption Custom markers. |
| 100 | +
|
| 101 | +````CSHTML |
| 102 | +@* This code snippet showcases an example of customizing the Marker appearance. *@ |
| 103 | +
|
| 104 | +<TelerikMap Center="@Center" |
| 105 | + Zoom="3"> |
| 106 | + <MapLayers> |
| 107 | + <MapLayer Type="@MapLayersType.Marker" |
| 108 | + Data="@MarkerData1" |
| 109 | + LocationField="@nameof(MarkerModel.LatLng)" |
| 110 | + TitleField="@nameof(MarkerModel.Title)"> |
| 111 | + <MapLayerMarkerSettings Template="<span class='custom-marker-class'>#= dataItem.Title #</span>"> |
| 112 | + </MapLayerMarkerSettings> |
| 113 | + </MapLayer> |
| 114 | +
|
| 115 | + <MapLayer Type="@MapLayersType.Tile" |
| 116 | + Attribution="@Attribution" |
| 117 | + Subdomains="@Subdomains" |
| 118 | + UrlTemplate="@UrlTemplate"> |
| 119 | + </MapLayer> |
| 120 | +
|
| 121 | + <MapLayer Type="@MapLayersType.Marker" |
| 122 | + Data="@MarkerData2" |
| 123 | + LocationField="@nameof(MarkerModel.LatLng)" |
| 124 | + TitleField="@nameof(MarkerModel.Title)"> |
| 125 | + <MapLayerMarkerSettings Template="#= dataItem.LatLng #"> |
| 126 | + </MapLayerMarkerSettings> |
| 127 | + </MapLayer> |
| 128 | + </MapLayers> |
| 129 | +</TelerikMap> |
| 130 | +
|
| 131 | +@code { |
| 132 | + public string[] Subdomains { get; set; } = new string[] { "a", "b", "c" }; |
| 133 | + public string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"; |
| 134 | + public string Attribution { get; set; } = "© <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>"; |
| 135 | + public double[] Center { get; set; } = new double[] { 30.268107, -97.744821 }; |
85 | 136 |
|
86 |
| - |
| 137 | + public List<MarkerModel> MarkerData1 { get; set; } = new List<MarkerModel>() |
| 138 | + { |
| 139 | + new MarkerModel() |
| 140 | + { |
| 141 | + LatLng = new double[] { 30.268107, -97.744821 }, |
| 142 | + Title = "Austin, TX" |
| 143 | + }, |
| 144 | + }; |
87 | 145 |
|
88 |
| -## Marker Shapes |
| 146 | + public List<MarkerModel> MarkerData2 { get; set; } = new List<MarkerModel>() |
| 147 | + { |
| 148 | + new MarkerModel() |
| 149 | + { |
| 150 | + LatLng = new double[] { 37.7749, -122.4194 }, |
| 151 | + Title = "San Francisco, CA" |
| 152 | + } |
| 153 | + }; |
| 154 | +
|
| 155 | + public class MarkerModel |
| 156 | + { |
| 157 | + public double[] LatLng { get; set; } |
| 158 | + public string Title { get; set; } |
| 159 | + } |
| 160 | +} |
89 | 161 |
|
90 |
| -The Markers in Map are two types - **Pin** and **PinTarget**. They can be defined using the `Shape` parameter of the `MapLayer` tag. The default visual appearance of the Marker is the **PinTarget**. |
| 162 | +<style> |
| 163 | + .custom-marker-class { |
| 164 | + background-image: url(https://demos.telerik.com/kendo-ui/content/shared/icons/16/star.png); |
| 165 | + background-color: palegoldenrod; |
| 166 | + color: blue; |
| 167 | + background-size: 9px; |
| 168 | + width: 62px; |
| 169 | + background-repeat: no-repeat; |
| 170 | + display: inline-table; |
| 171 | + font-size: 14px; |
| 172 | + padding-top: 5px; |
| 173 | + } |
| 174 | +</style> |
| 175 | +```` |
91 | 176 |
|
92 |
| ->caption Different Marker Shapes. |
| 177 | +## Defining the Marker Shapes |
93 | 178 |
|
94 |
| - |
| 179 | +The Map supports the `Pin` and `PinTarget` Marker types. To define the Marker type, use the `Shape` parameter of the `MapLayer` tag. By default, the visual appearance of the Marker is `PinTarget`. |
95 | 180 |
|
96 |
| ->caption The example for the above result. |
| 181 | +>caption Different Marker shapes. |
97 | 182 |
|
98 | 183 | ````CSHTML
|
99 |
| -@* This code snippet showcases an example of the different Marker Shapes. *@ |
| 184 | +@* This code snippet showcases an example of the different Marker shapes. *@ |
100 | 185 |
|
101 | 186 | <TelerikMap Center="@Center" Zoom="3">
|
102 | 187 | <MapLayers>
|
@@ -152,18 +237,14 @@ The Markers in Map are two types - **Pin** and **PinTarget**. They can be define
|
152 | 237 | }
|
153 | 238 | ````
|
154 | 239 |
|
155 |
| -## Marker Tooltip Settings |
156 |
| - |
157 |
| -The `MapLayerMarkerSettingsTooltip` tag allows you to fine tune the tooltips content, appearance and options. You can fully customize the HTML content of the tooltip. |
| 240 | +## Setting the Marker Tooltip |
158 | 241 |
|
159 |
| ->caption Marker Tooltip Template. |
| 242 | +The `MapLayerMarkerSettingsTooltip` tag allows you to fine-tune the content, appearance, and options of the tooltip, as well as fully customize its HTML content. |
160 | 243 |
|
161 |
| - |
162 |
| - |
163 |
| ->caption The example for the above result. |
| 244 | +>caption Marker tooltip template. |
164 | 245 |
|
165 | 246 | ````CSHTML
|
166 |
| -@* This code snippet showcases an example of the Marker Tooltip Settings. *@ |
| 247 | +@* This code snippet showcases an example of the Marker tooltip settings. *@ |
167 | 248 |
|
168 | 249 | <TelerikMap Center="@Center"
|
169 | 250 | Zoom="3">
|
@@ -229,4 +310,4 @@ The `MapLayerMarkerSettingsTooltip` tag allows you to fine tune the tooltips con
|
229 | 310 | public string Title { get; set; }
|
230 | 311 | }
|
231 | 312 | }
|
232 |
| -```` |
| 313 | +```` |
0 commit comments