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

    HTML
    JavaScript
    <div id="vectorMap"></div>
    $(function() {
        $("#vectorMap").dxVectorMap({
            layers: [{
                type: 'area',
                dataSource: DevExpress.viz.map.sources.world,
                label: {
                    enabled: true,
                    dataField: 'name'
                }
            }]
        });
    });
  • 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 Wrappers

    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.

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.

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 component 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()

Returns the root HTML element of the widget.

endUpdate()

Enables the component to refresh after the beginUpdate() method call.

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.

hideLoadingIndicator()

Conceals the loading indicator.

instance()

Returns an instance of this component class.

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()

Returns the configuration options of this component.

option(optionName)

Gets the value of the specified configuration option of this component.

option(optionName, optionValue)

Sets a value to the specified configuration option of this component.

option(options)

Sets one or more options of this component.

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

Fires when the widget is being removed.

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

Fires after an option of the component 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.

Map Elements

This section lists the methods and fields of the map elements.