JavaScript/jQuery Map Options
See Also
accessKey
The value of this property will be passed to the accesskey
attribute of the HTML element that underlies the UI component.
activeStateEnabled
The UI component switches to the active state when users press down the primary mouse button. When this property is set to true, the CSS rules for the active state apply. You can change these rules to customize the component.
Use this property when you display the component on a platform whose guidelines include the active state change for UI components.
apiKey
If you have more than one map provider in your application, specify the keys in the object fields as shown below. Otherwise, you can assign the key directly to the apiKey property.
jQuery
$(function() { $("#mapContainer").dxMap({ // ... apiKey: { bing: "MY_BING_MAPS_KEY", google: "MY_GOOGLE_MAPS_KEY", googleStatic: "MY_GOOGLE_STATIC_MAPS_KEY" } }); });
Angular
<dx-map ... > <dxo-api-key bing="MY_BING_MAPS_KEY" google="MY_GOOGLE_MAPS_KEY" googleStatic="MY_GOOGLE_STATIC_MAPS_KEY"> </dxo-api-key> </dx-map>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { }
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxMapModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxMapModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
<template> <DxMap ... > <DxApiKey bing="MY_BING_MAPS_KEY" google="MY_GOOGLE_MAPS_KEY" googleStatic="MY_GOOGLE_STATIC_MAPS_KEY" /> </DxMap> </template> <script> import 'devextreme/dist/css/dx.light.css'; import DxMap, { DxApiKey } from 'devextreme-vue/map'; export default { components: { DxMap, DxApiKey } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import Map, { ApiKey } from 'devextreme-react/map'; const App = () => { return ( <Map ... > <ApiKey bing="MY_BING_MAPS_KEY" google="MY_GOOGLE_MAPS_KEY" googleStatic="MY_GOOGLE_STATIC_MAPS_KEY" /> </Map> ); } export default App;
autoAdjust
Specifies whether the UI component automatically adjusts center and zoom property values when adding a new marker or route, or if a new UI component contains markers or routes by default.
If autoAdjust is enabled, zoom is set to the maximum value allowing all markers and routes to be displayed at the same time. The center is changed so that markers and routes are aligned with the UI component's center. Set the autoAdjust property to false to disable this behavior.
Note that the zoom level can only be automatically decreased to display all markers and routes. If the current zoom level allows all routes and markers to be displayed on the map, it remains unchanged.
center
An object, a string, or an array specifying which part of the map is displayed at the UI component's center using coordinates. The UI component can change this value if autoAdjust is enabled.
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
jQuery
$(function(){ $("#mapContainer").dxMap({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-map ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-map>
import { DxMapModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxMapModule ], // ... })
Vue
<template> <DxMap ... :element-attr="mapAttributes"> </DxMap> </template> <script> import DxMap from 'devextreme-vue/map'; export default { components: { DxMap }, data() { return { mapAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import Map from 'devextreme-react/map'; class App extends React.Component { mapAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <Map ... elementAttr={this.mapAttributes}> </Map> ); } } export default App;
height
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"20vh"
,"80%"
,"inherit"
.Function (deprecated since v21.2)
Refer to the W0017 warning description for information on how you can migrate to viewport units.
markerIconSrc
To set a custom icon for an individual marker, specify the iconSrc field of the corresponding marker data source object.
markers[]
If you use the Knockout approach when working with the Map UI component, you can pass an observable array to the markers property to easily manage markers.
onClick
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
onDisposing
A function that is executed before the UI component is disposed of.
Name | Type | Description |
---|---|---|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
onInitialized
Name | Type | Description |
---|---|---|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
Angular
<dx-map ... (onInitialized)="saveInstance($event)"> </dx-map>
import { Component } from "@angular/core"; import Map from "devextreme/ui/data_grid"; // ... export class AppComponent { mapInstance: Map; saveInstance (e) { this.mapInstance = e.component; } }
Vue
<template> <div> <DxMap ... @initialized="saveInstance"> </DxMap> </div> </template> <script> import DxMap from 'devextreme-vue/map'; export default { components: { DxMap }, data: function() { return { mapInstance: null }; }, methods: { saveInstance: function(e) { this.mapInstance = e.component; } } }; </script>
<template> <div> <DxMap ... @initialized="saveInstance"> </DxMap> </div> </template> <script setup> import DxMap from 'devextreme-vue/map'; let mapInstance = null; const saveInstance = (e) => { mapInstance = e.component; } </script>
React
import Map from 'devextreme-react/map'; class App extends React.Component { constructor(props) { super(props); this.saveInstance = this.saveInstance.bind(this); } saveInstance(e) { this.mapInstance = e.component; } render() { return ( <div> <Map onInitialized={this.saveInstance} /> </div> ); } }
See Also
onMarkerAdded
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
options |
The added marker's data. |
|
originalMarker |
The original marker that the current map provider uses (only for "google" and "bing" providers). |
onMarkerRemoved
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
options |
The removed marker's data. |
onOptionChanged
Name | Type | Description |
---|---|---|
value | any |
The modified property's new value. |
previousValue | any |
The UI component's previous value. |
name |
The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into. |
|
fullName |
The path to the modified property that includes all parent properties. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
The following example shows how to subscribe to component property changes:
jQuery
$(function() { $("#mapContainer").dxMap({ // ... onOptionChanged: function(e) { if(e.name === "changedProperty") { // handle the property change here } } }); });
Angular
<dx-map ... (onOptionChanged)="handlePropertyChange($event)"> </dx-map>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { // ... handlePropertyChange(e) { if(e.name === "changedProperty") { // handle the property change here } } }
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxMapModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxMapModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
<template> <DxMap ... @option-changed="handlePropertyChange" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import DxMap from 'devextreme-vue/map'; export default { components: { DxMap }, // ... methods: { handlePropertyChange: function(e) { if(e.name === "changedProperty") { // handle the property change here } } } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import Map from 'devextreme-react/map'; const handlePropertyChange = (e) => { if(e.name === "changedProperty") { // handle the property change here } } export default function App() { return ( <Map ... onOptionChanged={handlePropertyChange} /> ); }
onReady
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
originalMap |
The current provider's map data. |
You can use component
field to access properties that are common for all supported Map providers. To access provider-specific API, utilize the originalMap
parameter. The examples below demonstrate this solution:
onRouteAdded
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
options |
The added route's data. |
|
originalRoute |
The original route that the current map provider uses (only for "google" and "bing" providers). |
onRouteRemoved
Name | Type | Description |
---|---|---|
component |
The UI component's instance. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
options |
The removed route's data. |
provider
Use the "googleStatic" provider to connect route points directly rather than by following the street layout.
On May 21, 2024, Microsoft announced that Bing Maps for Enterprise and its API will be discontinued. Azure Maps will be a single unified enterprise mapping platform available from Microsoft.
We are working on API compatible with Azure Maps and expect to ship it with our next major release (v24.2). If you have an existing license to Bing Maps for Enterprise, you can continue using our existing API. You need to transition to new API until June 30, 2025 (free and basic license) or until June 30, 2028 (enterprise license).
The last date you can get a new license to Bing Maps for Enterprise is June 30, 2024. If you do not have an existing license after that date, you would not be able to use our map controls with Bing Maps or Azure Maps (until we release the new API). During that time, you can use other map providers supported by our controls, such as Google or GoogleStatic.
rtlEnabled
When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
DevExpress.config({ rtlEnabled: true });
tabIndex
The value of this property will be passed to the tabindex
attribute of the HTML element that underlies the UI component.
width
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"20vw"
,"80%"
,"auto"
,"inherit"
.Function (deprecated since v21.2)
Refer to the W0017 warning description for information on how you can migrate to viewport units.