- Notifications
You must be signed in to change notification settings - Fork 80
docs(map):added documentation for the map component #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits Select commit Hold shift + click to select a range
5c5b4e1
docs(map):added documentation for the map component
xristianstefanov e08f7aa
docs(map):fixes as per comments
xristianstefanov 12385e8
docs(map):changed name of the zoom section
xristianstefanov 6250ef8
docs(map):reversed sentences
xristianstefanov 84f93a6
docs(map):fixes as per last comments
xristianstefanov bc0337d
docs(map):reduced json
xristianstefanov 7b44db7
docs(map):rewording in layer sections
xristianstefanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,324 @@ | ||
--- | ||
title: Events | ||
page_title: Map - Events | ||
description: Discover the Blazor Map events and explore the examples. | ||
slug: components/map/events | ||
tags: telerik,blazor,map,events,event | ||
published: true | ||
position: 11 | ||
--- | ||
| ||
# Map Events | ||
| ||
This article explains the available events for the Telerik Map for Blazor: | ||
| ||
* [OnClick](#onclick) | ||
* [OnMarkerClick](#onmarkerclick) | ||
* [OnShapeClick](#onshapeclick) | ||
| ||
## OnClick | ||
| ||
The `OnClick` event fires when the user clicks on the map. Its `EventCallback<MapClickEventArgs>` gives: | ||
* `MapClickEventArgs.EventArgs` - provides the native DOM event (browser event). | ||
* `MapClickEventArgs.Location` - provides the location of the click on the map (`MapLocation` has `Latitude` and `Longitude` props). | ||
| ||
>caption Handle OnClick. | ||
| ||
````CSHTML | ||
@* This code snippet showcases an example of how to handle the OnClick event. *@ | ||
| ||
<TelerikMap Center="@Center" | ||
Zoom="3" | ||
OnClick="@OnMapClick"> | ||
<MapLayers> | ||
<MapLayer Type="@MapLayersType.Tile" | ||
Attribution="@Attribution" | ||
Subdomains="@Subdomains" | ||
UrlTemplate="@UrlTemplate"> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Bubble" | ||
Data="@BubbleData" | ||
LocationField="@nameof(BubbleModel.LatLng)" | ||
ValueField="@nameof(BubbleModel.Revenue)"> | ||
<MapLayerBubbleSettings> | ||
<MapLayerBubbleSettingsStyle> | ||
<MapLayerBubbleSettingsStyleFill Color="#0000ff"></MapLayerBubbleSettingsStyleFill> | ||
<MapLayerBubbleSettingsStyleStroke Color="#000000"></MapLayerBubbleSettingsStyleStroke> | ||
</MapLayerBubbleSettingsStyle> | ||
</MapLayerBubbleSettings> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Marker" | ||
Data="@MarkerData1" | ||
LocationField="@nameof(MarkerModel.LatLng)" | ||
TitleField="@nameof(MarkerModel.Title)"> | ||
</MapLayer> | ||
</MapLayers> | ||
</TelerikMap> | ||
| ||
<strong>@EventResult</strong> | ||
| ||
@code { | ||
public string[] Subdomains { get; set; } = new string[] { "a", "b", "c" }; | ||
public string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"; | ||
public string Attribution { get; set; } = "© <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>"; | ||
public double[] Center { get; set; } = new double[] { 30.268107, -97.744821 }; | ||
public string EventResult { get; set; } | ||
| ||
public List<MarkerModel> MarkerData1 { get; set; } = new List<MarkerModel>() | ||
{ | ||
new MarkerModel() | ||
{ | ||
LatLng = new double[] { 30.268107, -97.744821 }, | ||
Title = "Austin, TX" | ||
} | ||
}; | ||
| ||
public List<BubbleModel> BubbleData { get; set; } = new List<BubbleModel>() | ||
{ | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 37.7749, -122.4194 }, | ||
Revenue = 1000 | ||
}, | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 41.8781, -87.6298 }, | ||
Revenue = 200 | ||
} | ||
}; | ||
| ||
public void OnMapClick(MapClickEventArgs args) | ||
{ | ||
var location = args.Location; | ||
var eventArgs = args.EventArgs as MouseEventArgs; | ||
| ||
LogToConsole( | ||
$"map click: location = [{location.Latitude}, {location.Longitude}]," + | ||
$"clientX = {eventArgs.ClientX}, clientY = {eventArgs.ClientY}"); | ||
} | ||
| ||
public void LogToConsole(string text) | ||
{ | ||
EventResult = text; | ||
} | ||
| ||
public class MarkerModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public string Title { get; set; } | ||
} | ||
| ||
public class BubbleModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public int Revenue { get; set; } | ||
} | ||
} | ||
```` | ||
| ||
## OnMarkerClick | ||
| ||
The `OnMarkerClick` event fires when the user clicks on a marker. Its `EventCallback<MapMarkerClickEventArgs>` gives: | ||
* `MapMarkerClickEventArgs.DataItem` - provides the data item (object) of the bound marker. | ||
* `MapMarkerClickEventArgs.EventArgs` - provides the native DOM event (browser event). | ||
| ||
>caption Handle OnMarkerClick. | ||
| ||
````CSHTML | ||
@* This code snippet showcases an example of how to handle the OnMarkerClick event. *@ | ||
| ||
<TelerikMap Center="@Center" | ||
Zoom="3" | ||
OnMarkerClick="@OnMarkerClick"> | ||
<MapLayers> | ||
<MapLayer Type="@MapLayersType.Tile" | ||
Attribution="@Attribution" | ||
Subdomains="@Subdomains" | ||
UrlTemplate="@UrlTemplate"> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Bubble" | ||
Data="@BubbleData" | ||
LocationField="@nameof(BubbleModel.LatLng)" | ||
ValueField="@nameof(BubbleModel.Revenue)"> | ||
<MapLayerBubbleSettings> | ||
<MapLayerBubbleSettingsStyle> | ||
<MapLayerBubbleSettingsStyleFill Color="#0000ff"></MapLayerBubbleSettingsStyleFill> | ||
<MapLayerBubbleSettingsStyleStroke Color="#000000"></MapLayerBubbleSettingsStyleStroke> | ||
</MapLayerBubbleSettingsStyle> | ||
</MapLayerBubbleSettings> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Marker" | ||
Data="@MarkerData1" | ||
LocationField="@nameof(MarkerModel.LatLng)" | ||
TitleField="@nameof(MarkerModel.Title)"> | ||
</MapLayer> | ||
</MapLayers> | ||
</TelerikMap> | ||
| ||
<strong>@EventResult</strong> | ||
| ||
@code { | ||
public string[] Subdomains { get; set; } = new string[] { "a", "b", "c" }; | ||
public string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"; | ||
public string Attribution { get; set; } = "© <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>"; | ||
public double[] Center { get; set; } = new double[] { 30.268107, -97.744821 }; | ||
public string EventResult { get; set; } | ||
| ||
public List<MarkerModel> MarkerData1 { get; set; } = new List<MarkerModel>() | ||
{ | ||
new MarkerModel() | ||
{ | ||
LatLng = new double[] { 30.268107, -97.744821 }, | ||
Title = "Austin, TX" | ||
} | ||
}; | ||
| ||
public List<BubbleModel> BubbleData { get; set; } = new List<BubbleModel>() | ||
{ | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 37.7749, -122.4194 }, | ||
Revenue = 1000 | ||
}, | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 41.8781, -87.6298 }, | ||
Revenue = 200 | ||
} | ||
}; | ||
| ||
public void OnMarkerClick(MapMarkerClickEventArgs args) | ||
{ | ||
var dataItem = args.DataItem as MarkerModel; | ||
var eventArgs = args.EventArgs as MouseEventArgs; | ||
| ||
LogToConsole( | ||
$"marker click: title = {dataItem.Title}, location = [{string.Join(",", dataItem.LatLng)}]," + | ||
$"clientX = {eventArgs.ClientX}, clientY = {eventArgs.ClientY}"); | ||
} | ||
| ||
public void LogToConsole(string text) | ||
{ | ||
EventResult = text; | ||
} | ||
| ||
public class MarkerModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public string Title { get; set; } | ||
} | ||
| ||
public class BubbleModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public int Revenue { get; set; } | ||
} | ||
} | ||
```` | ||
| ||
## OnShapeClick | ||
| ||
The `OnShapeClick` event fires when the user clicks on a shape. Its `EventCallback<MapShapeClickEventArgs>` gives: | ||
* `MapShapeClickEventArgs.DataItem` - provides the data item when the shape is coming from a bubble layer (null for shape layer). | ||
* `MapShapeClickEventArgs.GeoJsonDataItem` - provides the data item in the form of GeoJSON (dictionary) when the layer is a shape layer (null for bubble layer). | ||
* `MapShapeClickEventArgs.EventArgs` - provides the native DOM event (browser event). | ||
| ||
>caption Handle OnShapeClick. | ||
| ||
````CSHTML | ||
@* This code snippet showcases an example of how to handle the OnShapeClick event. *@ | ||
| ||
<TelerikMap Center="@Center" | ||
Zoom="3" | ||
OnShapeClick="@OnShapeClick"> | ||
<MapLayers> | ||
<MapLayer Type="@MapLayersType.Tile" | ||
Attribution="@Attribution" | ||
Subdomains="@Subdomains" | ||
UrlTemplate="@UrlTemplate"> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Bubble" | ||
Data="@BubbleData" | ||
LocationField="@nameof(BubbleModel.LatLng)" | ||
ValueField="@nameof(BubbleModel.Revenue)"> | ||
<MapLayerBubbleSettings> | ||
<MapLayerBubbleSettingsStyle> | ||
<MapLayerBubbleSettingsStyleFill Color="#0000ff"></MapLayerBubbleSettingsStyleFill> | ||
<MapLayerBubbleSettingsStyleStroke Color="#000000"></MapLayerBubbleSettingsStyleStroke> | ||
</MapLayerBubbleSettingsStyle> | ||
</MapLayerBubbleSettings> | ||
</MapLayer> | ||
| ||
<MapLayer Type="@MapLayersType.Marker" | ||
Data="@MarkerData1" | ||
LocationField="@nameof(MarkerModel.LatLng)" | ||
TitleField="@nameof(MarkerModel.Title)"> | ||
</MapLayer> | ||
</MapLayers> | ||
</TelerikMap> | ||
| ||
<strong>@EventResult</strong> | ||
| ||
@code { | ||
public string[] Subdomains { get; set; } = new string[] { "a", "b", "c" }; | ||
public string UrlTemplate { get; set; } = "https://#= subdomain #.tile.openstreetmap.org/#= zoom #/#= x #/#= y #.png"; | ||
public string Attribution { get; set; } = "© <a href='https://osm.org/copyright'>OpenStreetMap contributors</a>"; | ||
public double[] Center { get; set; } = new double[] { 30.268107, -97.744821 }; | ||
public string EventResult { get; set; } | ||
| ||
public List<MarkerModel> MarkerData1 { get; set; } = new List<MarkerModel>() | ||
{ | ||
new MarkerModel() | ||
{ | ||
LatLng = new double[] { 30.268107, -97.744821 }, | ||
Title = "Austin, TX" | ||
} | ||
}; | ||
| ||
public List<BubbleModel> BubbleData { get; set; } = new List<BubbleModel>() | ||
{ | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 37.7749, -122.4194 }, | ||
Revenue = 1000 | ||
}, | ||
new BubbleModel() | ||
{ | ||
LatLng = new double[] { 41.8781, -87.6298 }, | ||
Revenue = 200 | ||
} | ||
}; | ||
| ||
public void OnShapeClick(MapShapeClickEventArgs args) | ||
{ | ||
var dataItem = args.DataItem as BubbleModel; | ||
var eventArgs = args.EventArgs as MouseEventArgs; | ||
| ||
LogToConsole( | ||
$"shape click: revenue = {dataItem.Revenue}, location = [{string.Join(",", dataItem.LatLng)}]," + | ||
$"clientX = {eventArgs.ClientX}, clientY = {eventArgs.ClientY}"); | ||
} | ||
| ||
public void LogToConsole(string text) | ||
{ | ||
EventResult = text; | ||
} | ||
| ||
public class MarkerModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public string Title { get; set; } | ||
} | ||
| ||
public class BubbleModel | ||
{ | ||
public double[] LatLng { get; set; } | ||
public int Revenue { get; set; } | ||
} | ||
} | ||
```` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.