Class RadzenGoogleMap
RadzenGoogleMap component.
Implements
Inherited Members
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
Syntax
public class RadzenGoogleMap : RadzenComponent, IDisposable
Examples
<RadzenGoogleMap Zoom="3" Center=@(new GoogleMapPosition() { Lat = 42.6977, Lng = 23.3219 }) MapClick=@OnMapClick MarkerClick=@OnMarkerClick">
<Markers>
<RadzenGoogleMapMarker Title="London" Label="London" Position=@(new GoogleMapPosition() { Lat = 51.5074, Lng = 0.1278 }) />
<RadzenGoogleMapMarker Title="Paris " Label="Paris" Position=@(new GoogleMapPosition() { Lat = 48.8566, Lng = 2.3522 }) />
</Markers>
</RadzenGoogleMap>
@code {
void OnMapClick(GoogleMapClickEventArgs args)
{
Console.WriteLine($"Map clicked at Lat: {args.Position.Lat}, Lng: {args.Position.Lng}");
}
void OnMarkerClick(RadzenGoogleMapMarker marker)
{
Console.WriteLine($"Map {marker.Title} marker clicked. Marker position -> Lat: {marker.Position.Lat}, Lng: {marker.Position.Lng}");
}
}
Properties
ApiKey
Gets or sets the Google API key.
Declaration
public string ApiKey { get; set; }
Property Value
Type | Description |
---|---|
System.String | The Google API key. |
Center
Gets or sets the center map position.
Declaration
public GoogleMapPosition Center { get; set; }
Property Value
Type | Description |
---|---|
GoogleMapPosition | The center. |
Data
Gets or sets the data - collection of RadzenGoogleMapMarker.
Declaration
public IEnumerable<RadzenGoogleMapMarker> Data { get; set; }
Property Value
Type | Description |
---|---|
IEnumerable<RadzenGoogleMapMarker> | The data. |
FitBoundsToMarkersOnUpdate
Flag indicating whether map will be zoomed to marker bounds on update or not.
Declaration
public bool FitBoundsToMarkersOnUpdate { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MapClick
Gets or sets the map click callback.
Declaration
public EventCallback<GoogleMapClickEventArgs> MapClick { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<GoogleMapClickEventArgs> | The map click callback. |
MapId
Gets or sets the Google Map Id.
Declaration
public string MapId { get; set; }
Property Value
Type | Description |
---|---|
System.String | The Google Map Id. |
MarkerClick
Gets or sets the marker click callback.
Declaration
public EventCallback<RadzenGoogleMapMarker> MarkerClick { get; set; }
Property Value
Type | Description |
---|---|
EventCallback<RadzenGoogleMapMarker> | The marker click callback. |
Markers
Gets or sets the markers.
Declaration
public RenderFragment Markers { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment | The markers. |
Options
Gets or sets the Google map options: https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions.
Declaration
public Dictionary<string, object> Options { get; set; }
Property Value
Type | Description |
---|---|
Dictionary<System.String, System.Object> | The Google map options. |
Zoom
Gets or sets the zoom.
Declaration
public double Zoom { get; set; }
Property Value
Type | Description |
---|---|
System.Double | The zoom. |
Methods
AddMarker(RadzenGoogleMapMarker)
Adds the marker.
Declaration
public void AddMarker(RadzenGoogleMapMarker marker)
Parameters
Type | Name | Description |
---|---|---|
RadzenGoogleMapMarker | marker | The marker. |
Dispose()
Detaches event handlers and disposes Reference.
Declaration
public override void Dispose()
Overrides
GetComponentCssClass()
Gets the component CSS class.
Declaration
protected override string GetComponentCssClass()
Returns
Type | Description |
---|---|
System.String |
Overrides
OnAfterRenderAsync(Boolean)
Called by the Blazor runtime.
Declaration
protected override async Task OnAfterRenderAsync(bool firstRender)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | firstRender |
Returns
Type | Description |
---|---|
Task |
Overrides
OnMapClick(GoogleMapClickEventArgs)
Handles the MapClick event.
Declaration
public async System.Threading.Tasks.Task OnMapClick(GoogleMapClickEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GoogleMapClickEventArgs | args | The GoogleMapClickEventArgs instance containing the event data. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
OnMarkerClick(RadzenGoogleMapMarker)
Called when marker click.
Declaration
public async System.Threading.Tasks.Task OnMarkerClick(RadzenGoogleMapMarker marker)
Parameters
Type | Name | Description |
---|---|---|
RadzenGoogleMapMarker | marker | The marker. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
RemoveMarker(RadzenGoogleMapMarker)
Removes the marker.
Declaration
public void RemoveMarker(RadzenGoogleMapMarker marker)
Parameters
Type | Name | Description |
---|---|---|
RadzenGoogleMapMarker | marker | The marker. |