JavaScript/jQuery VectorMap Options
See Also
- Configure a Widget: Angular | Vue | React | jQuery | AngularJS | Knockout | ASP.NET MVC 5 | ASP.NET Core
bounds
When you need to display only a specific region on a map, specify the geographical coordinates of this region using the bounds option. Assign an array of four values to this option. These values represent geographical coordinates in the following format: [minLongitude, maxLatitude, maxLongitude, minLatitude] with the default range of longitude [-180, 180] and latitude [-90, 90]. See the image below to review how these values are applied to a map.
If your dataSource contains coordinates in a different range, implement a custom projection.
controlBar
Users can use the pan control and zoom bar in the control bar panel to navigate the map.
The following code shows how to use the controlBar object to move the control bar to the right side of the map:
jQuery
$(function() { $("#vectorMapContainer").dxVectorMap({ // ... controlBar: { horizontalAlignment: "right" } }); });
Angular
<dx-vector-map ... > <dxo-control-bar horizontalAlignment="right"> </dxo-control-bar> </dx-vector-map>
// ... import { DxVectorMapModule } from 'devextreme-angular'; @NgModule({ imports: [ // ... DxVectorMapModule ], // ... }) export class AppModule { }
Vue
<template> <DxVectorMap ... > <DxControlBar horizontal-alignment="right" /> </DxVectorMap> </template> <script> import { DxVectorMap, DxControlBar } from 'devextreme-vue/vector-map'; export default { components: { DxVectorMap, DxControlBar }, // ... } </script>
React
import React from 'react'; import { VectorMap, ControlBar } from 'devextreme-react/vector-map'; class App extends React.Component { render() { return ( <VectorMap> // ... <ControlBar horizontalAlignment="right" /> </VectorMap> ); } } export default App;
ASP.NET MVC Controls
@(Html.DevExtreme().VectorMap() @* ... *@ .ControlBar(cb => cb .HorizontalAlignment(HorizontalAlignment.Right) ) )
elementAttr
Specifies the attributes to be attached to the widget's root element.
jQuery
$(function(){ $("#vectorMapContainer").dxVectorMap({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-vector-map ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-vector-map>
import { DxVectorMapModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxVectorMapModule ], // ... })
Vue
<template> <DxVectorMap ... :element-attr="vectorMapAttributes"> </DxVectorMap> </template> <script> import DxVectorMap from 'devextreme-vue/vector-map'; export default { components: { DxVectorMap }, data() { return { vectorMapAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import VectorMap from 'devextreme-react/vector-map'; class App extends React.Component { vectorMapAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <VectorMap ... elementAttr={this.vectorMapAttributes}> </VectorMap> ); } } export default App;
export
These features allow a user to export your widget into a document or print it. When exporting is enabled, the "Exporting/Printing" button appears in the widget. A click on it invokes a drop-down menu that lists exporting and printing commands. The following formats are supported for exporting into: PNG, PDF, JPEG, SVG and GIF.
See Also
legends[]
A legend is a supplementary map element that helps end-users identify a map area or a map marker. The VectorMap widget can display several legends simultaneously. To configure legends, declare an array of objects and assign it to the legends option. Each object in this array specifies settings of one legend. These settings are described in this section.
Each legend requires the source option to be set. This option specifies whether it is areas or markers that must be accompanied with a legend. Learn more from the description of the source option.
A map legend contains several legend items. A legend item consists of a marker and a text. You can change the size of markers using the markerSize option. To provide texts for legend items, you need to implement the customizeText function.
loadingIndicator
When the widget is bound to a remote data source, it can display a loading indicator while data is loading.
To enable the automatic loading indicator, set the enabled option to true.
If you want to change the loading indicator's visibility, use the show option or the showLoadingIndicator() and hideLoadingIndicator() methods.
onCenterChanged
Name | Type | Description |
---|---|---|
center |
The updated geographical coordinates of the center. |
|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
onClick
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget'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 handler execution extended by the x and y fields. It is a dxEvent or a jQuery.Event when you use jQuery. |
jQueryEvent |
Use 'event' instead. The jQuery event that caused the handler execution. Deprecated in favor of the event field. |
|
model |
The model data. Available only if you use Knockout. |
|
target |
The Layer Element object (if available). |
The clicked point's coordinates are available in the event field's x and y properties. The coordinates are calculated relatively to the client area which is the widget's container. To convert them into map coordinates, use the convertCoordinates(x,y) method.
onDisposing
A function that is executed before the widget is disposed of.
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
Model data. Available only if you use Knockout. |
onDrawn
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
onExported
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
onExporting
Name | Type | Description |
---|---|---|
cancel |
Allows you to prevent exporting. |
|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
fileName |
The name of the file to which the widget is about to be exported. |
|
format |
The resulting file format. One of PNG, PDF, JPEG, SVG and GIF. |
|
model |
The model data. Available only if you use Knockout. |
onFileSaving
A function that is executed before a file with exported widget is saved to the user's local storage.
Name | Type | Description |
---|---|---|
cancel |
Allows you to prevent file saving. |
|
component |
The widget's instance. |
|
data |
Exported data as a BLOB. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
fileName |
The name of the file to be saved. |
|
format |
The format of the file to be saved. |
onIncidentOccurred
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
|
target | any |
Information on the occurred incident. |
The widget notifies you of errors and warnings by passing messages to the browser console. Each message contains the incident's ID, a brief description, and a link to the Errors and Warnings section where further information about this incident can be found.
The onIncidentOccurred function allows you to handle errors and warnings the way you require. The object passed to it contains the target field. This field provides information about the occurred incident and contains the following properties:
- id
The incident's ID. The full list of IDs can be found in the Errors and Warnings section. - type
The incident's type: "error" or "warning". - args
The argument of the incident's message. Depends on the incident. For example, it may be the name of the data source field that was specified incorrectly, or the name of the option that was not set properly. - text
The text passed to the browser's console. Includes the args content, if there is any. - widget
The name of the widget that produced the error or warning. - version
The used DevExtreme version.
onInitialized
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onOptionChanged
Name | Type | Description |
---|---|---|
model |
Model data. Available only if you use Knockout. |
|
fullName |
The path to the modified option that includes all parent options. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The widget's instance. |
|
name |
The modified option if it belongs to the first level. Otherwise, the first-level option it is nested into. |
|
value | any |
The modified option's new value. |
onSelectionChanged
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
|
target |
The selected/deselected layer element; described in the Layer Element section. |
To identify whether the selection has been applied or canceled, call the layer element's selected() method.
onTooltipHidden
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
|
target |
The layer element whose tooltip is hidden; described in the Layer Element section. |
onTooltipShown
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
|
target |
The layer element whose tooltip is shown; described in the Layer Element section. |
onZoomFactorChanged
Name | Type | Description |
---|---|---|
component |
The widget's instance. |
|
element |
The widget's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
model |
The model data. Available only if you use Knockout. |
|
zoomFactor |
The updated zoom factor. |
panningEnabled
Disables the panning capability.
Setting this option to false disables a user to pan the map. However, you still can pan the map in code using the center(centerCoordinates) and viewport(viewportCoordinates) methods.
pathModified
projection
You can use one of the following out-of-the-box projections:
- Mercator projection
- Equirectangular projection
- Lambert cylindrical projection
- Miller cylindrical projection
To set a custom projection, implement two functions (from and to) that convert coordinates between geographical and widget coordinate systems. In addition, set the projection's aspectRatio.
redrawOnResize
Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates.
When this option is set to true, the widget will be redrawn automatically in case the size of its parent window changes.
rtlEnabled
When this option is set to true, the widget 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 });
size
The widget occupies its container's entire area by default. Use the size object to specify the widget's size if it should be different from that of its container. Assign 0 to size object's height and width options to hide the widget.
jQuery
$(function() { $("#vectorMapContainer").dxVectorMap({ // ... size: { height: 300, width: 600 } }); });
Angular
<dx-vector-map ... > <dxo-size [height]="300" [width]="600"> </dxo-size> </dx-vector-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 { DxVectorMapModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxVectorMapModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
<template> <DxVectorMap ... > <DxSize :height="300" :width="600" /> </DxVectorMap> </template> <script> import DxVectorMap, { DxSize } from 'devextreme-vue/vector-map'; export default { components: { DxVectorMap, DxSize }, // ... } </script>
React
import React from 'react'; import VectorMap, { Size } from 'devextreme-react/vector-map'; class App extends React.Component { render() { return ( <VectorMap ... > <Size height={300} width={600} /> </VectorMap> ); } } export default App;
Alternatively, you can style the widget's container using CSS:
jQuery
$(function() { $("#vectorMap").dxVectorMap({ // ... }); });
#vectorMap { width: 85%; height: 70%; }
Angular
<dx-vector-map ... id="vectorMap"> </dx-vector-map>
#vectorMap { width: 85%; height: 70%; }
Vue
<template> <DxVectorMap ... id="vectorMap"> </DxVectorMap> </template> <script> import DxVectorMap from 'devextreme-vue/vector-map'; export default { components: { DxVectorMap }, // ... } </script> <style> #vectorMap { width: 85%; height: 70%; } </style>
React
import React from 'react'; import VectorMap from 'devextreme-react/vector-map'; class App extends React.Component { render() { return ( <VectorMap ... id="vectorMap"> </VectorMap> ); } } export default App;
#vectorMap { width: 85%; height: 70%; }
theme
A theme is a widget configuration that gives the widget a distinctive appearance. Use can use one of the predefined themes or create a custom one. Changing the option values in the widget's configuration object overrides the theme's corresponding values.
Use the VizTheme
enum to specify this option when the widget is used as an ASP.NET MVC 5 Control or a DevExtreme-Based ASP.NET Core Control. This enum accepts the following values: GenericLight
, GenericDark
, GenericContrast
, GenericCarmine
, GenericDarkMoon
, GenericSoftBlue
, GenericDarkViolet
, GenericGreenMist
, MaterialBlueLight
, MaterialLimeLight
, MaterialOrangeLight
, MaterialPurpleLight
, MaterialTealLight
.
title
The widget's title is a short text that usually indicates what is visualized. If you need to specify the title's text only, assign it directly to the title option. Otherwise, set this option to an object with the text and other fields specified.
The title can be accompanied by a subtitle elaborating on the visualized subject using the title.subtitle object.
tooltip
A tooltip is a miniature rectangle displaying data of an area or a marker. A tooltip appears when the end-user hovers the cursor over an area or a marker. To show tooltips, do the following.
Enable tooltips.
Set the enabled option to true.Specify text to be displayed in tooltips. Specify the customizeTooltip option.
You can also change the appearance of tooltips using fields of the tooltip configuration object.
wheelEnabled
Rolling the mouse wheel zooms a map. If you need to disable this capability, assign false to the wheelEnabled option. A user will still be able to zoom the map using the control bar.
zoomFactor
Use this option to specify a zoom factor for a map while configuring it. This option accepts a value that is greater than 1. Note that the zooming is performed with relation to the center of the map.
zoomingEnabled
Disables the zooming capability.
Setting this option to false disables a user's ability to zoom the map. However, you can still zoom the map in code using the zoomFactor(zoomFactor) method.
If you have technical questions, please create a support ticket in the DevExpress Support Center.