Map

The Map is an interactive widget that displays a geographic map with markers and routes.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Module: ui/map
Export: default
Map interactive configuration
Copy Code
Copy to Codepen
$("#map").dxMap({
});

                    

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

  • jQuery

    HTML
    JavaScript
    <div id="map"></div>
    $(function () {
        $("#map").dxMap({
            provider: 'bing',
            type: 'roadmap',
            zoom: 10,
            center: "40.749825, -73.987963"
        });
    });
  • Angular

    HTML
    <dx-map
        provider="bing"
        type="roadmap"
        [zoom]="10"
        center="40.749825, -73.987963">
    </dx-map>
  • AngularJS

    HTML
    <div dx-map="{
        provider: 'bing',
        type: 'roadmap',
        zoom: 10,
        center: '40.749825, -73.987963'
    }"></div>
  • Knockout

    HTML
    <div data-bind="dxMap: {
        provider: 'bing',
        type: 'roadmap',
        zoom: 10,
        center: '40.749825, -73.987963'
    }"></div>
  • ASP.NET MVC Wrappers

    Razor C#
    Razor VB
    @(Html.DevExtreme().Map()
        .ID("map")
        .Provider(GeoMapProvider.Bing)
        .Type(GeoMapType.Roadmap)
        .Zoom(10)
        .Center(40.749825, -73.987963)
    )
    @(Html.DevExtreme().Map() _
        .ID("map") _
        .Provider(GeoMapProvider.Bing) _
        .Type(GeoMapType.Roadmap) _
        .Zoom(10) _
        .Center(40.749825, -73.987963)
    )

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.

See Also

View Demo

Configuration

An object defining configuration options for the Map widget.

Name Description
accessKey

Specifies a shortcut key that sets focus on the widget element.

activeStateEnabled

A Boolean value specifying whether or not the widget changes its state when interacting with a user.

autoAdjust

Specifies whether or not the widget automatically adjusts center and zoom option values when adding a new marker or route, or when creating a widget if it initially contains markers or routes.

center

An object, a string, or an array specifying the location displayed at the center of the widget.

controls

Specifies whether or not map widget controls are available.

disabled

A Boolean value specifying whether or not the widget can respond to user interaction.

elementAttr

Specifies the attributes to be attached to the widget's root element.

focusStateEnabled

Specifies whether or not the widget can be focused.

height

Specifies the height of the widget.

hint

Specifies the text of the hint displayed for the widget.

hoverStateEnabled

A Boolean value specifying whether or not the widget changes its state when being hovered by an end user.

key

A key used to authenticate the application within the required map provider.

markerIconSrc

A URL pointing to the custom icon to be used for map markers.

markers

An array of markers displayed on a map.

onClick

A handler for the click event.

onDisposing

A handler for the disposing event.

onInitialized

A handler for the initialized event. Executed only once, after the widget is initialized.

onMarkerAdded

A handler for the markerAdded event.

onMarkerRemoved

A handler for the markerRemoved event.

onOptionChanged

A handler for the optionChanged event.

onReady

A handler for the ready event.

onRouteAdded

A handler for the routeAdded event.

onRouteRemoved

A handler for the routeRemoved event.

provider

The name of the current map data provider.

routes

An array of routes shown on the map.

rtlEnabled

Specifies whether or not the current component supports a right-to-left representation.

tabIndex

Specifies the widget tab index.

type

The type of a map to display.

visible

A Boolean value specifying whether or not the widget is visible.

width

Specifies the width of the widget.

zoom

The zoom level of the map.

Methods

This section describes members used to manipulate a widget.

Name Description
addMarker(markerOptions)

Adds a marker to the map.

addRoute(routeOptions)

Adds a route to the map.

beginUpdate()

Prevents the component from refreshing until the endUpdate() method is called.

defaultOptions(rule)

Specifies the device-dependent default configuration options for this component.

element()

Returns the root HTML element of the widget.

endUpdate()

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

focus()

Sets focus on the widget.

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.

registerKeyHandler(key, handler)

Registers a handler when a specified key is pressed.

removeMarker(marker)

Removes a marker from the map.

removeRoute(route)

Removes a route from the map.

repaint()

Redraws the widget.

Events

This section describes events fired by this widget.

Name Description
click

Fires when the map is clicked.

disposing

Fires when the widget is being removed.

initialized

Raised only once, after the widget is initialized.

markerAdded

Fires after a marker is added to the map.

markerRemoved

Fires after a marker is removed from the map.

optionChanged

Fires after an option of the component is changed.

ready

Fires after a map is rendered.

routeAdded

Fires after a route is added to the map.

routeRemoved

Fires after a route is removed from the map.