Vue VectorMap API
The VectorMap is a widget that visualizes geographical locations. This widget represents a geographical map that contains areas and markers. Areas embody continents and countries. Markers flag specific points on the map, for example, towns, cities or capitals.
DevExtreme widgets are integrated with many popular libraries and frameworks. See the Installation section (for JavaScript libraries) or the Prerequisites and Installation section (for ASP.NET MVC framework) to find details on setting up DevExtreme with a particular library or framework.
The following code shows how to create the VectorMap widget using every supported library and framework. For more details on working with widgets in these libraries and frameworks, see the Widget Basics topic for jQuery, Angular, AngularJS, Knockout or ASP.NET MVC.
jQuery
$(function() { $("#vectorMap").dxVectorMap({ layers: [{ type: 'area', dataSource: DevExpress.viz.map.sources.world, label: { enabled: true, dataField: 'name' } }] }); });
<div id="vectorMap"></div>
Angular
<dx-vector-map> <dxi-layer type="area" [dataSource]="worldMap"> <dxo-label [enabled]="true" dataField="name"> </dxo-label> </dxi-layer> </dx-vector-map>
import { DxVectorMapModule } from 'devextreme-angular'; import * as maps from 'vectormap-data/world.js'; // ... export class AppComponent { worldMap: any = maps.world; } @NgModule({ imports: [ // ... DxVectorMapModule ], // ... })
AngularJS
<div dx-vector-map="{ layers: [{ type: 'area', dataSource: DevExpress.viz.map.sources.world, label: { enabled: true, dataField: 'name' } }] }"></div>
Knockout
<div data-bind="dxVectorMap: { layers: [{ type: 'area', dataSource: DevExpress.viz.map.sources.world, label: { enabled: true, dataField: 'name' } }], }"></div>
ASP.NET MVC Controls
@(Html.DevExtreme().VectorMap() .Layers(layers => { layers.Add() .DataSource(new JS("DevExpress.viz.map.sources.world")) .Label(l => l .Enabled(true) .DataField("name") ); }) )
@(Html.DevExtreme().VectorMap() _ .Layers(Sub(layers) layers.Add() _ .DataSource(New JS("DevExpress.viz.map.sources.world")) _ .Label(Sub(l) l.Enabled(true) _ .DataField("name") End Sub) End Sub) )
See Also
Props
Name | Description |
---|---|
background |
Specifies the options for the map background. |
bounds |
Specifies the positioning of a map in geographical coordinates. |
center |
Specifies the geographical coordinates of the center for a map. |
controlBar |
Specifies the options of the control bar. |
elementAttr |
Specifies the attributes to be attached to the widget's root element. |
export |
Configures the exporting and printing features. |
layers |
Specifies options for VectorMap widget layers. |
legends |
Configures map legends. |
loadingIndicator |
Configures the loading indicator. |
maxZoomFactor |
Specifies a map's maximum zoom factor. |
onCenterChanged |
A handler for the centerChanged event. |
onClick |
A handler for the click event. |
onDisposing |
A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only. |
onDrawn |
A function that is executed when the widget's rendering has finished. |
onExported |
A handler for the exported event. Executed after data from the widget is exported. |
onExporting |
A handler for the exporting event. Executed before data from the widget is exported. |
onFileSaving |
A handler for the fileSaving event. Executed before a file with exported data is saved on the user's local storage. |
onIncidentOccurred |
A handler for the incidentOccurred event. Executed when an error or warning appears in the widget. |
onInitialized |
A handler for the initialized event. Executed only once, after the widget is initialized. |
onOptionChanged |
A handler for the optionChanged event. Executed after an option of the widget is changed. |
onSelectionChanged |
A handler for the selectionChanged event. |
onTooltipHidden |
A handler for the tooltipHidden event. |
onTooltipShown |
A handler for the tooltipShown event. |
onZoomFactorChanged |
A handler for the zoomFactorChanged event. |
panningEnabled |
Disables the panning capability. |
pathModified |
Notifies the widget that it is embedded into an HTML page that uses a tag modifying the path. |
projection |
Specifies the map projection. |
redrawOnResize |
Specifies whether to redraw the widget when the size of the parent browser window changes or a mobile device rotates. |
rtlEnabled |
Switches the widget to a right-to-left representation. |
size |
Specifies the widget's size in pixels. |
theme |
Sets the name of the theme the widget uses. |
title |
Configures the widget's title. |
tooltip |
Configures tooltips. |
touchEnabled |
Specifies whether the map should respond to touch gestures. |
wheelEnabled |
Specifies whether or not the map should respond when a user rolls the mouse wheel. |
zoomFactor |
Specifies a number that is used to zoom a map initially. |
zoomingEnabled |
Disables the zooming capability. |
Methods
This section describes the methods that can be used in code to manipulate objects related to the widget.
Name | Description |
---|---|
beginUpdate() |
Prevents the widget from refreshing until the endUpdate() method is called. |
center() |
Gets the current map center coordinates. |
center(centerCoordinates) |
Sets the map center coordinates. |
clearSelection() |
Deselects all the selected area and markers on a map at once. The areas and markers are displayed in their initial style after. |
convertCoordinates(x, y) |
Converts client area coordinates into map coordinates. |
dispose() |
Disposes of all the resources allocated to the VectorMap instance. |
element() |
Gets the root widget element. |
endUpdate() |
Refreshes the widget after a call of the beginUpdate() method. |
exportTo(fileName, format) |
Exports the widget. |
getInstance(element) |
Gets the instance of a widget found using its DOM node. |
getLayerByIndex(index) |
Gets a layer with a specific index. |
getLayerByName(name) |
Gets a layer with a specific name. |
getLayers() |
Gets all layers. |
getSize() |
Gets the current widget size. |
hideLoadingIndicator() |
Hides the loading indicator. |
instance() |
Gets the widget's instance. Use it to access other methods of the widget. |
off(eventName) |
Detaches all event handlers from a single event. |
off(eventName, eventHandler) |
Detaches a particular event handler from a single event. |
on(eventName, eventHandler) |
Subscribes to an event. |
on(events) |
Subscribes to events. |
option() |
Gets all widget options. |
option(optionName) |
Gets the value of a single option. |
option(optionName, optionValue) |
Updates the value of a single option. |
option(options) |
Updates the values of several options. |
print() |
Opens the browser's print window. |
render() |
Redraws the widget. |
showLoadingIndicator() |
Shows the loading indicator. |
svg() |
Gets the widget's SVG markup. |
viewport() |
Gets the current map viewport coordinates. |
viewport(viewportCoordinates) |
Sets the map viewport coordinates. |
zoomFactor() |
Gets the current zoom factor value. |
zoomFactor(zoomFactor) |
Sets the zoom factor value. |
Events
Name | Description |
---|---|
centerChanged |
Fires when the coordinates of the map center are changed. |
click |
Fires when a user clicks on any place on the map. |
disposing |
Raised when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only. |
drawn |
Raised when the widget's rendering has finished. |
exported |
Raised after data from the widget is exported. |
exporting |
Raised before data from the widget is exported. |
fileSaving |
Raised before a file with exported data is saved on the user's local storage. |
incidentOccurred |
Raised when an error or warning appears in the widget. |
initialized |
Raised only once, after the widget is initialized. |
optionChanged |
Raised after a widget option is changed. |
selectionChanged |
Fires when a user selects/deselects a layer element. |
tooltipHidden |
Fires when a tooltip of an area or marker becomes hidden. |
tooltipShown |
Fires when a tooltip of an area or marker appears. |
zoomFactorChanged |
Fires when the map zoom factor is changed. |
If you have technical questions, please create a support ticket in the DevExpress Support Center.