VectorMap

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.

Included in: dx.viz.js, dx.viz-web.js, dx.all.js
Module: viz/vector_map
Export: default
VectorMap interactive configuration
Copy Code
Copy to Codepen
$("#vectormap").dxVectorMap({
});

                    

You can create the widget using one of the following approaches.

jQuery
JavaScript
HTML
$(function() {
    $("#vectorMap").dxVectorMap({
        layers: [{
            type: 'area',
            dataSource: DevExpress.viz.map.sources.world,
            label: {
                enabled: true,
                dataField: 'name'
            }
        }]
    });
});
<div id="vectorMap"></div>
Angular
HTML
<dx-vector-map>
    <dxi-layer
        type="area"
        [dataSource]="DevExpress.viz.map.sources.world">
        <dxo-label
            [enabled]="true"
            dataField="name">
        </dxo-label>
    </dxi-layer>
</dx-vector-map>
AngularJS
HTML
<div dx-vector-map="{
    layers: [{
        type: 'area',
        dataSource: DevExpress.viz.map.sources.world,
        label: {
            enabled: true,
            dataField: 'name'
        }
    }]
}"></div>
Knockout
HTML
<div data-bind="dxVectorMap: {
    layers: [{
        type: 'area',
        dataSource: DevExpress.viz.map.sources.world,
        label: {
            enabled: true,
            dataField: 'name'
        }
    }],
}"></div>
ASP.NET MVC Controls
Razor C#
Razor VB
@(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)
)

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

View Demo Watch Video

See Also

Configuration

An object that specifies configuration options for the widget.

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 handler for the drawn event.

onExported

A handler for the exported event.

onExporting

A handler for the exporting event.

onFileSaving

A handler for the fileSaving event.

onIncidentOccurred

A handler for the incidentOccurred event.

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

Specifies whether or not the widget supports right-to-left representation.

size

Specifies the size of the widget in pixels.

theme

Sets the name of the theme to be used in the widget.

title

Specifies the widget 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 coordinates of the map center.

center(centerCoordinates)

Sets the coordinates of the map center.

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.

element()

Gets the root element of the widget.

endUpdate()

Refreshes the widget after a call of the beginUpdate() method.

exportTo(fileName, format)

Exports the widget into a document with a specified name and format.

getLayerByIndex(index)

Gets the layer by its index.

getLayerByName(name)

Gets the layer by its name.

getLayers()

Gets all map layers.

getSize()

Gets the current size of the widget.

hideLoadingIndicator()

Conceals the loading indicator.

instance()

Returns this widget's instance. Use it to access other methods of the widget.

off(eventName)

Detaches all event handlers from the specified event.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

on(eventName, eventHandler)

Subscribes to a specified event.

on(events)

Subscribes to the specified events.

option()

Gets the widget's options.

option(optionName)

Gets a specific option value.

option(optionName, optionValue)

Assigns a new value to a specific option.

option(options)

Sets one or more options.

print()

Opens the browser's print window.

render()

Redraws the widget.

showLoadingIndicator()

Displays the loading indicator.

svg()

Returns the widget's SVG markup.

viewport()

Gets the current coordinates of the map viewport.

viewport(viewportCoordinates)

Sets the coordinates of the map viewport.

zoomFactor()

Gets the current value of the map zoom factor.

zoomFactor(zoomFactor)

Sets the value of the map zoom factor.

Events

This section describes events fired by this widget.

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

Fires when the widget has finished drawing itself.

exported

Fires after data from the widget is exported.

exporting

Fires before data from the widget is exported.

fileSaving

Fires before a file with exported data is saved on the user's local storage.

incidentOccurred

Fires when an error or warning appears in a widget.

initialized

Raised only once, after the widget is initialized.

optionChanged

Raised after an option of the widget 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.

See Also

Map Elements

This section describes vector map elements.