Back to Devexpress

DxMap.MapClick Event

blazor-devexpress-dot-blazor-dot-dxmap-396e8b24.md

latest2.1 KB
Original Source

DxMap.MapClick Event

Fires when a user clicks a map.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public EventCallback<MapClickEventArgs> MapClick { get; set; }

Event Data

The MapClick event's data class is MapClickEventArgs. The following properties provide information specific to this event:

PropertyDescription
CurrentLocationReturns information about the clicked location.

Remarks

When a user clicks a map, the MapClick event fires. Use the event argument’s CurrentLocation property to get coordinates of the clicked location.

Run Demo: Map Markers

razor
<DxFormLayout >
    <DxFormLayoutItem Caption="Latitude:" ColSpanMd="6">
        <DxTextBox @bind-Text="@Latitude" />
    </DxFormLayoutItem>
    <DxFormLayoutItem Caption="Longitude:" ColSpanMd="6">
        <DxTextBox @bind-Text="@Longitude" />
    </DxFormLayoutItem>
    <DxFormLayoutItem ColSpanMd="12">
        <DxMap Zoom="14" Provider="MapProvider.Azure" Width="100%" Height="400px" MapClick=@OnMapClick >
            <DxMapApiKeys Azure="@MapApiKeyProvider.GetAzureProviderKey()" />
            <DxMapCenter GeoPosition="40.7061, -73.9969" />
        </DxMap>
    </DxFormLayoutItem>
</DxFormLayout>

@code {
    string Latitude;
    string Longitude;

    void OnMapClick(MapClickEventArgs e) {
        Latitude = e.CurrentLocation.Latitude.ToString("0.######");
        Longitude = e.CurrentLocation.Longitude.ToString("0.######");
    }
}

See Also

DxMap Class

DxMap Members

DevExpress.Blazor Namespace