Skip to content

Commit 885bde0

Browse files
xristianstefanovdmihaylo
andauthored
[4.1] docs(map): add article for custom map markers (#1357)
* docs(map): add article for custom map markers * docs(map): fixes as per comments * docs: add minor updates to marker layer * docs: update links --------- Co-authored-by: dmihaylo <[email protected]>
1 parent 3484ebe commit 885bde0

File tree

1 file changed

+107
-26
lines changed

1 file changed

+107
-26
lines changed

components/map/layers/marker.md

Lines changed: 107 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
11
---
22
title: Marker
33
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.
55
slug: components/map/layers/marker
6-
tags: telerik,blazor,map,layers,marker
6+
tags: telerikui, blazor, map, layers, marker
77
published: True
88
position: 5
99
---
1010

1111
# Marker Layer
1212

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.
1414

15-
**To configure a Map Layer of type Marker:**
15+
Sections in this article:
1616

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.
1827
2. Set the `Type` parameter of the `MapLayer` to `Marker`.
1928
3. Set the `Data` parameter.
2029
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).
2231

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.
2433

25-
>caption The Map Marker Layer configuration.
34+
>caption The Marker Map layer configuration.
2635
2736
````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. *@
2938
3039
<TelerikMap Center="@Center" Zoom="3">
3140
<MapLayers>
@@ -81,22 +90,98 @@ The following example demonstrates how to configure the Map Marker Layer.
8190
}
8291
````
8392

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; } = "&copy; <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>";
135+
public double[] Center { get; set; } = new double[] { 30.268107, -97.744821 };
85136
86-
![](../images/marker-layer.png)
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+
};
87145
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+
}
89161
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+
````
91176

92-
>caption Different Marker Shapes.
177+
## Defining the Marker Shapes
93178

94-
![Blazor Map Marker Shapes](../images/marker-shapes.png)
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`.
95180

96-
>caption The example for the above result.
181+
>caption Different Marker shapes.
97182
98183
````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. *@
100185
101186
<TelerikMap Center="@Center" Zoom="3">
102187
<MapLayers>
@@ -152,18 +237,14 @@ The Markers in Map are two types - **Pin** and **PinTarget**. They can be define
152237
}
153238
````
154239

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
158241

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.
160243

161-
![Blazor Map Marker ToolTip](../images/marker-tooltip-settings.png)
162-
163-
>caption The example for the above result.
244+
>caption Marker tooltip template.
164245
165246
````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. *@
167248
168249
<TelerikMap Center="@Center"
169250
Zoom="3">
@@ -229,4 +310,4 @@ The `MapLayerMarkerSettingsTooltip` tag allows you to fine tune the tooltips con
229310
public string Title { get; set; }
230311
}
231312
}
232-
````
313+
````

0 commit comments

Comments
 (0)