blazor-devexpress-dot-blazor-30fdd1e6.md
An interactive component that displays a geographic map with markers and routes.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
public class DxMap :
ClientComponentBase,
IModelProvider<MapApiKeyModel>,
IModelProvider<MapLocationModel>,
IModelProvider<ProviderConfigModel>,
IModelProvider<ClientComponentCollectionModel<MapMarkerModel>>,
IModelProvider<ClientComponentCollectionModel<MapRouteModel>>
The DevExpress Map for Blazor (<DxMap>) can display Google and Azure maps and allows you to create markers and routes. Built-in controls allow a user to zoom and navigate the map or change its type.
You must have a map API key to display maps in your application. For information on where to get a key, refer to the following topics:
Follow the steps below to add a Map component to an application:
.razor file: <DxMap>…</DxMap>.Azure, Google, or GoogleStatic.Important
Microsoft deprecated Bing Maps for Enterprise and specified retirement dates. This change is a part of Microsoft’s initiative to unify its enterprise map product offerings: Bing Maps for Enterprise and Azure Maps.
Our Blazor Map component now supports Azure Maps. To display Azure Maps in your application, set the Provider property to Azure and assign the corresponding API key to the DxMapApiKeys.Azure property.
Refer to the following article for additional information: Bing Maps for Enterprise Service Deprecation.
Refer to the following list for the component API reference: DxMap Members.
Blazor Map does not support static render mode. Enable interactivity to use the component in your application. Refer to the following topic for more details: Enable Interactive Render Mode.
The DxMap control automatically adjusts map center and zoom level to display all markers and routes. Set the AutoAdjust property to false to disable this behavior.
You can specify the map center and zoom level manually.
<DxMap Zoom="14" Provider="MapProvider.Azure" Width="100%" Height="600px" >
<DxMapApiKeys Azure="@MapApiKeyProvider.GetAzureProviderKey()" />
<DxMapCenter GeoPosition="40.7061, -73.9969" />
</DxMap>
Manual map adjustment can be useful when automatic adjustment is not available:
DxMap displays a static Google Map image.false.Set the ControlsVisible property to true to display map type and navigation controls.
<DxMap Zoom="14" Provider="MapProvider.Azure" Width="100%" Height="600px" ControlsVisible="true" >
<DxMapApiKeys Azure="@MapApiKeyProvider.GetAzureProviderKey()" />
<DxMapCenter GeoPosition="40.7061, -73.9969" />
</DxMap>
To create a map marker, follow the steps below:
<DxMap Zoom="14" Provider="MapProvider.Azure" Width="950px" Height="400px" >
<DxMapApiKeys Azure="@MapApiKeyProvider.GetAzureProviderKey()" />
<DxMapMarkers>
<DxMapMarker>
<DxMapMarkerLocation GeoPosition="51.519852,-0.077593" />
<DxMapMarkerTooltip Text="Spitalfields Market" Visible="true" />
</DxMapMarker>
<DxMapMarker>
<DxMapMarkerLocation GeoPosition="51.514763,-0.080787" />
<DxMapMarkerTooltip Text="The Gherkin" Visible="true" />
</DxMapMarker>
<DxMapMarker>
<DxMapMarkerLocation GeoPosition="51.508029,-0.078674" />
<DxMapMarkerTooltip Text="Tower of London" Visible="true" />
</DxMapMarker>
</DxMapMarkers>
</DxMap>
To create a route, follow the steps below:
Walking or Driving.<DxMap Zoom="14" Provider="MapProvider.Azure" Width="950px" Height="400px" ControlsVisible="true" >
<DxMapApiKeys Azure="@MapApiKeyProvider.GetAzureProviderKey()" />
<DxMapRoutes>
<DxMapRoute Color="green" Weight="9" Mode="MapRouteMode.Walking" >
<DxMapRouteLocations>
<DxMapRouteLocation GeoPosition="St. Paul's Cathedral,London" />
<DxMapRouteLocation GeoPosition="Tate Modern,London" />
</DxMapRouteLocations>
</DxMapRoute>
<DxMapRoute Color="red" Weight="9" Mode="MapRouteMode.Driving" >
<DxMapRouteLocations>
<DxMapRouteLocation GeoPosition="St. Paul's Cathedral,London" />
<DxMapRouteLocation GeoPosition="Tate Modern,London" />
</DxMapRouteLocations>
</DxMapRoute>
</DxMapRoutes>
</DxMap>
Object ComponentBase DxComponentBase DevExpress.Blazor.ClientComponents.Internal.ClientComponentBase DxMap
See Also