Description
The esri.Map class creates a container and required DOM structure for adding
layers,
graphics, an
info window, and other navigation controls.
Typically, a map is added to a page using a DIV. The map's width and height are initialized to those of the DIV container.
The Map.onLoad event is fired after the first layer has been added to the map. At this point, the map is fully functional. A Map.onLoad handler function should be used to add content and change map behaviors.
For an introduction on using the Map class, see
Adding a map.
Samples
Search for
samples that use this class.
Class hierarchy
esri.Map
Constructors
| new esri.Map(divId,options?) | Creates a new map inside of the given HTML container, which is often a DIV element. The size of the map is the size of the container. The Map constructor can also include optional parameters. The optional parameters can be included in any order. |
CSS
| esriAttribution | Represents the map attribution node.
.esriAttribution{
color:#B20000 !important;
font-weight:bold;
}
|
| esriAttributionOpen | Represents the map attribution node when it is open i.e., it is clicked. Use this class to define CSS rules that apply to the attribution only when it is open.
.esriAttributionOpen{
font-style:italic;
}
|
Properties
| attribution | Attribution | Reference to the attribution widget created by the map when map attribution is enabled. |
| autoResize | Boolean | Value is true when the map automatically resizes if the browser window or ContentPane widget enclosing the map is resized. Otherwise false. |
| extent | Extent | The current extent of the map in map units. This property is read-only. |
| fadeOnZoom | Boolean | Indicates if the fade effect is enabled while zooming. Only applicable when navigationMode is set to 'css-transforms'. The default value is true. |
| force3DTransforms | Boolean | When the mapNavigation mode is set to 'css-transforms', CSS3 transforms will be used for map navigation when supported by the browser. It is recommended that you let the map determine when to enable transformations to avoid running into a known issue with scrollbar rendering on Chrome on Windows XP. |
| geographicExtent | Extent | The extent (or bounding box) of the map in geographic coordinates. Available only when the map's spatial reference is Web Mercator or Geographic (wkid 4326). |
| graphics | GraphicsLayer | Provides access to the Map's GraphicsLayer. The graphics object is available to use after the Map.onLoad event. |
| graphicsLayerIds | String[] | An array of the current GraphicsLayers in the map. |
| height | Number | Current height of the map in screen pixels. |
| id | String | Reference to HTML DIV or other element where the map is placed on the page. This property is set in the Map constructor. |
| infoWindow | Popup | Displays the InfoWindow on a map. |
| isClickRecenter | Boolean | When true, the key sequence of shift then click to recenter the map is enabled. |
| isDoubleClickZoom | Boolean | When true, double click zoom is enabled. This allows a user to zoom and recenter the map by double clicking the mouse. |
| isKeyboardNavigation | Boolean | When true, keyboard navigation is enabled. This allows users to pan the keyboard using the arrow keys and to zoom using the + and - keys. |
| isPan | Boolean | When true, map panning is enabled using the mouse. |
| isPanArrows | Boolean | When true, pan arrows are displayed around the edge of the map. |
| isRubberBandZoom | Boolean | When true, rubberband zoom is enabled. This allows users to draw a bounding box zoom area using the mouse. |
| isScrollWheelZoom | Boolean | When true, the mouse scroll wheel zoom is enabled. |
| isShiftDoubleClickZoom | Boolean | When true, shift double click zoom is enabled. This allows a user to zoom and recenter the map by shift + double clicking the mouse. |
| isZoomSlider | Boolean | When true, the zoom slider is displayed on the map. |
| layerIds | String[] | Array of current TiledMapServiceLayers and DynamicMapServiceLayers added to the map. |
| loaded | Boolean | After the first layer is loaded, the value is set to true. |
| navigationMode | String | Indicates whether the map uses CSS3 transformations when panning and zooming. In 'css-transform' mode the map will use CSS3 transformations, if supported by the browser, to provide a smoother experience while panning and zooming the map. |
| position | Point | This point geometry in screen coordinates represent the top-left corner of the map container. This coordinate also acts as the origin for all screen coordinates returned by Map and GraphicsLayer events. |
| root | DOMNode | The DOM node that contains the container of layers, build-in info window, logo and slider. |
| showAttribution | Boolean | When true, map attribution is enabled. |
| snappingManager | SnappingManager | If snapping is enabled on the map using map.enableSnapping() this property provides access to the SnappingManager. The snapping manager's setLayerInfo method can be used to modify the target snapping layers. |
| spatialReference | SpatialReference | The spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. |
| timeExtent | TimeExtent | The current TimeExtent for the map. Use the setTimeExtent method to modify the time extent. |
| width | Number | Current width of the map in screen pixels. |
Methods
| addLayer(layer,index?) | Layer | Adds an ESRI Layer to the map.
The return object of Layer was added at v1.4. |
| addLayers(layers) | None | Adds multiple layers to a map. The array order corresponds to the layer order in the client side map. |
| centerAndZoom(mapPoint,levelOrFactor) | Deferred | Centers and zooms the map.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the operation is completed. |
| centerAt(mapPoint) | Deferred | Centers the map based on map coordinates as the center point.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the map has been re-centered to the given point. |
| destroy() | None | Destroys the map instance. After the map is destroyed it is no longer valid however you can re-use the div element of the map to create a new map instance. |
| disableClickRecenter() | None | Disallows clicking on a map to center it. |
| disableDoubleClickZoom() | None | Disallows double clicking on a map to zoom in a level and center the map. |
| disableKeyboardNavigation() | None | Disallows panning and zooming using the keyboard. |
| disableMapNavigation() | None | Disallows all map navigation except the slider and pan arrows. |
| disablePan() | None | Disallows panning a map using the mouse. |
| disableRubberBandZoom() | None | Disallows zooming in or out on a map using a bounding box. |
| disableScrollWheelZoom() | None | Disallows zooming in or out on a map using the mouse scroll wheel. |
| disableShiftDoubleClickZoom() | undefined | Disallows shift double clicking on a map to zoom in a level and center the map. |
| disableSnapping() | None | Disables snapping on the map. |
| enableClickRecenter() | None | Permits users to click on a map to center it. |
| enableDoubleClickZoom() | None | Permits users to double click on a map to zoom in a level and center the map. |
| enableKeyboardNavigation() | None | Permits users to pan and zoom using the keyboard. |
| enableMapNavigation() | None | Allows all map navigation. |
| enablePan() | None | Permits users to pan a map using the mouse. |
| enableRubberBandZoom() | None | Permits users to zoom in or out on a map using a bounding box. |
| enableScrollWheelZoom() | None | Permits users to zoom in or out on a map using the mouse scroll wheel. |
| enableShiftDoubleClickZoom() | None | Permits users to shift double click on a map to zoom in a level and center the map. |
| enableSnapping(snapOptions?) | SnappingManager | Enable snapping on the map when working with the Editor, Measurement widget or the Draw and Edit toolbars. |
| getBasemap() | String | Returns the name of the current basemap. |
| getInfoWindowAnchor(screenCoords) | String | Sets an InfoWindow's anchor when calling InfoWindow.show. |
| getLayer(id) | Layer | Returns an individual layer of a map. |
| getLayersVisibleAtScale() | Layer[] | Return an array of layers visible at the current scale. |
| getLevel() | Number | Gets the current level of detail for the map. Valid only with an ArcGISTiledMapService layer. |
| getMaxScale() | Number | Returns the maximum visible scale of the map. You cannot zoom-in beyond this scale. A value of 0 indicates that the map does not have a maximum scale constraint. |
| getMaxZoom() | Number | Returns the maximum zoom level of the map. You cannot zoom in beyond this value. A value of -1 indicates that the map does not have pre-defined zoom levels. |
| getMinScale() | Number | Returns the minimum visible scale of the map. You cannot zoom out beyond this scale. A value of 0 indicates that the map does not have a maximum scale constraint. |
| getMinZoom() | Number | Returns the minimum zoom level of the map.You cannot zoom out beyond this value. A value of -1 indicates that the map does not have pre-defined zoom levels. |
| getScale() | Number | Returns the current map scale. |
| getZoom() | Number | Returns the current zoom level of the map. A value of -1 indicates that the map does not have pre-defined zoom levels. |
| hidePanArrows() | None | Hides the pan arrows from the map. |
| hideZoomSlider() | None | Hides the zoom slider from the map. |
| panDown() | Deferred | Pans the map south. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panLeft() | Deferred | Pans the map west. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
|
| panLowerLeft() | Deferred | Pans the map southwest. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panLowerRight() | Deferred | Pans the map southeast. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panRight() | Deferred | Pans the map east. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panUp() | Deferred | Pans the map north. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panUpperLeft() | Deferred | Pans the map northwest. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| panUpperRight() | Deferred | Pans the map northeast. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed. |
| removeAllLayers() | None | Removes all layers from the map.
The map's extent, spatial reference, and tiling scheme if defined do not change when the layers are removed. When the next layer is added to the map, this layer is displayed at the same extent and spatial reference. |
| removeLayer(layer) | None | Removes the specified layer from the map. |
| reorderLayer(layer,index) | None | Changes the layer order in the map. |
| reposition() | None | Repositions the map DIV on the page. This method should be used after the map DIV has been repostioned. |
| resize(immediate?) | None | Resizes the map DIV. This method should be used after the map DIV has been resized. |
| setBasemap(basemap) | None | Change the map's current basemap. |
| setExtent(extent,fit?) | Deferred. | Sets the extent of the map. The extent must be in the same spatial reference as the map.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the extent change has been committed by the map. |
| setLevel(level) | Deferred | Sets the map to the specified level. Zooms to the new level based on the current map center point. Valid only with an ArcGISTiledMapService layer.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the zoom level has been changed. |
| setMapCursor(cursor) | None | Sets the default cursor for the map. This cursor is shown whenever the mouse is pointed over the map, except when panning by dragging the map or using SHIFT+Drag to zoom. If not set, the map uses the platform-dependent default cursor, usually an arrow. |
| setScale(scale) | Deferred | Sets the map scale to the specified value. The value must be greater than 0.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the map scale has been changed. |
| setTimeExtent(timeExtent) | None | Sets the TimeExtent for the map. |
| setTimeSlider(timeSlider) | None | Set the time slider associated with the map. |
| setZoom(zoom) | Deferred | Set the map zoom level to the given value. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the zoom level has been changed. |
| showPanArrows() | None | Shows the pan arrows on the map. |
| showZoomSlider() | None | Shows the zoom slider on the map. |
| toMap(screenPoint) | Point | Converts a single screen point or an array of screen points to map coordinates. |
| toScreen(mapPoint) | Point | Converts a single map point or an array of map points to screen coordinates. |
Events
[ On Style Events | Connect Style Events ]
| onBasemapChange() | Fired when the map's basemap is changed. |
| onClick(event) | Fires when a user single clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. |
| onDblClick(event) | Fires when a user double clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. |
| onExtentChange(extent,delta,levelChange,lod) | Fires when the extent of the map has changed. |
| onKeyDown(keyEvent) | Fires when a keyboard key is pressed. |
| onKeyUp(keyEvent) | Fires when a keyboard key is released. |
| onLayerAdd(layer) | Fires any time a layer is added to the map. |
| onLayerAddResult(layer,error) | Fires after specified layer has been added to the map. |
| onLayerRemove() | Fires after the layer has been removed. |
| onLayerReorder(layer,index) | Fires when the map layer order has been changed. |
| onLayerResume(layer) | Fires when a map layer resumes drawing. |
| onLayerSuspend(layer) | Fires when a map layer suspends drawing. A layer is considered suspended when one of the following is true:
- The layer is hidden.
- The layer is not visible at the current map scale.
- The layer is explicitly suspended by calling the
Layer.suspend method.
|
| onLayersAddResult(results) | Fires after all layers are added to the map using the map.addLayers method. |
| onLayersRemoved() | Fires after all the layers have been removed. |
| onLayersReordered(layerIds) | Fires when all the layers have been reordered. |
| onLoad(map) | Fires when the first or base layer has been successfully added to the map. |
| onMouseDown(event) | Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page. |
| onMouseDrag(event) | Fires while the mouse is being dragged until the mouse button is released. |
| onMouseDragEnd(event) | Fires when a mouse button is released and the user stops dragging the mouse. |
| onMouseDragStart(event) | Fires when a mouse button is pressed down and the user starts to drag the mouse. |
| onMouseMove(event) | Fires any time the mouse pointer moves over the map region. A common use for this event is to show the current x,y coordinate of the map as the user moves the mouse pointer. |
| onMouseOut(event) | Fires when the mouse moves out of the map region of the HTML page. |
| onMouseOver(event) | Fires when the mouse moves into the map region of the HTML page. |
| onMouseUp(event) | Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page. |
| onMouseWheel(event) | Fires when the mouse wheel is scrolled. |
| onPan(extent,delta) | Fires during the pan process. |
| onPanEnd(extent,delta) | Fires when the pan is complete. |
| onPanStart(extent,startPoint) | Fires when a user commences panning. |
| onReposition(x,y) | Fires when the map DIV is repositioned. |
| onResize(extent,width,height) | Fires when the map's container has been resized. |
| onTimeExtentChange(timeExtent) | Fires when the map's timeExtent property is set. |
| onUnload(map) | Fires when the page is refreshed. |
| onUpdateEnd() | Fires after layers that are updating their content have completed. This event is often used in combination with onUpdateStart to display a "Map is busy" or "Loading..." message as visual feedback to the end-user. |
| onUpdateStart() | Fires when one or more layers being updating their content. This event is often used in combination with onUpdateEnd to display a "Map is busy" or "Loading..." message as visual feedback to the end-user. |
| onZoom(extent,zoomFactor,anchor) | Fires during the zoom process. |
| onZoomEnd(extent,zoomFactor,anchor,level) | Fires when the zoom is complete. |
| onZoomStart(extent,zoomFactor,anchor,level) | Fires when a user commences zooming. |
All On Style event listeners receive a single event object. The event properties listed below are accessed from this event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
| basemap-change | None | Fired when the map's basemap is changed. Should be used in favor of onBaseChange |
| click | <MouseEvent> <MouseEvent> | Fires when a user single clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. Should be used in favor of onClick |
| dbl-click | <MouseEvent> <MouseEvent> | Fires when a user double clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. Should be used in favor of onDblClick |
| extent-change | <Extent> extent <Point> delta <Boolean> levelChange <LOD> lod | Fires when the extent of the map has changed. Should be used in favor of onExtentChange |
| key-down | <KeyboardEvent> <KeyboardEvent> | Fires when a keyboard key is pressed. Should be used in favor of onKeyDown |
| key-up | <KeyboardEvent> <KeyboardEvent> | Fires when a keyboard key is released. Should be used in favor of onKeyUp |
| layer-add | <Layer> layer | Fires any time a layer is added to the map. Should be used in favor of onLayerAdd |
| layer-add-result | <Layer> layer <Error> error | Fires after specified layer has been added to the map. Should be used in favor of onLayerAddResult |
| layer-remove | <Layer> layer | Fires after the layer has been removed. Should be used in favor of onLayerRemove |
| layer-reorder | <Layer> layer <Number> index | Fires when the map layer order has been changed. Should be used in favor of onLayerReorder |
| layer-resume | <Layer> layer | Fires when a map layer resumes drawing. Should be used in favor of onLayerResume |
| layers-add-result | <Layer[]> layers | Fires after all layers are added to the map using the map.addLayers method. Should be used in favor of onLayersAddResult. |
| layers-removed | None | Fires after all the layers have been removed. Should be used in favor of onLayersRemoved |
| layers-reordered | <Number[]> layerIds | Fires when all the layers have been reordered. Should be used in favor of onLayersReordered |
| load | <Map> map | Fires when the first or base layer has been successfully added to the map. Should be used in favor of onLoad |
| mouse-down | <MouseEvent> <MouseEvent> | Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page. Should be used in favor of onMouseDown |
| mouse-drag | <MouseEvent> <MouseEvent> | Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag |
| mouse-drag-end | <MouseEvent> <MouseEvent> | Fires when a mouse button is released and the user stops dragging the mouse. Should be used in favor of onMouseDragEnd |
| mouse-drag-start | <MouseEvent> <MouseEvent> | Fires when a mouse button is pressed down and the user starts to drag the mouse. Should be used in favor of onMouseDragStart |
| mouse-move | <MouseEvent> <MouseEvent> | Fires any time the mouse pointer moves over the map region. A common use for this event is to show the current x,y coordinate of the map as the user moves the mouse pointer. Should be used in favor of onMouseMove |
| mouse-out | <MouseEvent> <MouseEvent> | Fires when the mouse moves out of the map region of the HTML page. Should be used in favor of onMouseOut |
| mouse-over | <MouseEvent> <MouseEvent> | Fires when the mouse moves into the map region of the HTML page.. Should be used in favor of onMouseOver |
| mouse-up | <MouseEvent> <MouseEvent> | Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page. Should be used in favor of onMouseUp |
| mouse-wheel | <MouseEvent> <MouseEvent> | Fires when the mouse wheel is scrolled. Should be used in favor of onMouseWheel |
| pan | <Extent> extent <Point> delta | Fires during the pan process. Should be used in favor of onPan |
| pan-end | <Point> delta <Extent> extent | Fires when the pan is complete. Should be used in favor of onPanEnd |
| pan-start | <Extent> extent | Fires when a user commences panning. Should be used in favor of onPanStart |
| reposition | <Number> x <Number> y | Fires when the map DIV is repositioned. Should be used in favor of onReposition |
| resize | <Extent> extent <Number> width <Number> height | Fires when the map's container has been resized. Should be used in favor of onResize |
| time-extent-change | <TimeExtent> timeExtent | Fires when the map's timeExtent property is set. Should be used in favor of onTimeExtentChange |
| unload | <Map> map | Fires when the page is refreshed. Should be used in favor of onUnload |
| update-end | <Error> error | Fires after layers that are updating their content have completed. This event is often used in combination with onUpdateStart to display a 'Map is busy' or 'Loading...' message as visual feedback to the end-user.. Should be used in favor of onUpdateEnd |
| update-start | None | Fires when one or more layers being updating their content. This event is often used in combination with onUpdateEnd to display a 'Map is busy' or 'Loading...' message as visual feedback to the end-user. Should be used in favor of onUpdateStart |
| zoom | <Extent> extent <Number> zoomFactor <Point> anchor | Fires during the zoom process. Should be used in favor of onZoom |
| zoom-end | <Extent> extent <Number> zoomFactor <Point> anchor <Number> level | Fires when the zoom is complete. Should be used in favor of onZoomEnd |
| zoom-start | <Extent> extent <Number> zoomFactor <Point> anchor <Number> level | Fires when a user commences zooming. Should be used in favor of onZoomStart |
Constructor Details
new esri.Map(divId,options?)
Creates a new map inside of the given HTML container, which is often a DIV element. The size of the map is the size of the container. The Map constructor can also include optional parameters. The optional parameters can be included in any order.
Parameters:
| <String> divId | Required | Container id for the referencing map. Required. |
| <Object> options | Optional | Optional parameters. See options list. |
Options:
| <Number> attributionWidth | Width of the attribution node relative to the map width. The default value is 0.45 i.e., 45% of the map width. As of v 3.1. |
| <Boolean > autoResize | When true the map will automatically resize when the browser window is resized or when the ContentPane widget enclosing the map is resized. The default value is true. |
| <String> basemap | Specify a basemap for the map. The following are valid options: "streets" , "satellite" , "hybrid", "topo", "gray", "oceans", "national-geographic", "osm". As of version 3.3 |
| <Number[] | Point> center | The location where the map should be centered. Enter the location as an array containing longitude and latitude (for example, [-98, 40]) or as an esri.geometry.Point. As of version 3.3 |
| <Boolean> displayGraphicsOnPan | When true, graphics are displayed during panning. When false, the graphics are turned off during pan movement. Setting to false may improve performance in Internet Explorer. The default is true. |
| <Extent> extent | If provided, the extent and projection of the map is set to the properties of Extent. Once the projection is set, all layers must be able to be drawn in the defined projection. The tiling scheme of an ArcGISTiledMapServiceLayer must match the projection of the map. The projection of the extent is honored as of v1.2 when used in the map constructor.
function init() {
var map = new esri.Map("map", {
extent: new esri.geometry.Extent({xmin:-20098296,ymin:-2804413,xmax:5920428,ymax:15813776,spatialReference:{wkid:54032}})
});
var dynamicMSLayer = new esri.layers.ArcGISDynamicMapServiceLayer
("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer")
map.addLayer(dynamicMSLayer);
}
|
| <Boolean> fadeOnZoom | When true a fade effect is enabled for supported layers. Currently only tiled layers are supported. This option is not applicable if navigationMode is set to classic. (As of v2.6)
var map = new esri.Map("map",{
extent:initExtent,
fadeOnZoom:true
});
|
| <Boolean> fitExtent | When true, for maps that contain tiled map service layers, you are guaranteed to have the initial extent defined using the extent constructor option shown completely on the map. As of v2.0
var map = new esri.Map("map",{extent:initExtent,fitExtent:true});
|
| <Boolean> force3DTransforms | When the mapNavigation mode is set to 'css-transforms', CSS3 transforms will be used for map navigation when supported by the browser. It is recommended that you let the map determine when to enable transformations to avoid running into a known issue with scrollbar rendering on Chrome on Windows XP.(As of v2.6)
map = new esri.Map("map",{
extent:initExtent,
force3DTransforms:true
});
var map = new esri.Map("map",{
extent:initExtent,
force3DTransforms:true
});
|
| <InfoWindowBase> infoWindow | By default the map creates and uses an out-of-the-box Popup. If you create a custom implementation using InfoWindowBase specify it using this option.
var infoWindow = new myModules.InfoWindow({
domNode: dojo.create("div", null, dojo.byId("map"))
});
var map = new esri.Map("map", {
extent: initExtent,
infoWindow:infoWindow
});
|
| <LOD[]> lods | If provided, the map is initialized with the specified levels of detail. All ArcGISTiledMapServiceLayers added to the map must have matching resolutions in order to be displayed. (As of v1.2)
var lods = [
{"level" : 0, "resolution" : 0.010986328125, "scale" : 4617149.97766929},
{"level" : 1, "resolution" : 0.0054931640625, "scale" : 2308574.98883465},
{"level" : 2, "resolution" : 0.00274658203125, "scale" : 1154287.49441732},
{"level" : 3, "resolution" : 0.001373291015625, "scale" : 577143.747208662},
{"level" : 4, "resolution" : 0.0006866455078125, "scale" : 288571.873604331}
];
var map = new esri.Map("map", {
lods: lods
});
|
| <Boolean> logo | Display the esri logo on the map. The default value is true.
map = new esri.Map("map", {
extent: initExtent,
logo:false
});
|
| <Number> maxScale | Maximum visible scale of the map. You cannot zoom in beyond this scale. The value will be further adjusted based on the maxZoom. As of version 3.3 |
| <Number> maxZoom | Maximum map zoom level. You cannot zoom out beyond this level. If a value is not provided, the maximum zoom level will be calculated based on maxScale or the maximum zoom level supported by the basemap. As of version 3.3 |
| <Number> minScale | Minimum visible scale of the map. You cannot zoom out beyond this scale. The specified value will be further adjusted based on the minZoom. As of version 3.3 |
| <Number> minZoom | Minimum map zoom level. You cannot zoom out beyond this level. If a value is not provided, the minimum zoom will be calculated based on maxScale or the maximum zoom level supported by the basemap. As of version 3.3 |
| <Boolean> nav | Displays pan buttons on map. When false, the pan arrows never display. The default is false. |
| <String> navigationMode | Specify whether or not to use CSS3 transformations when panning and zooming. Valid values are "css-transforms" or "classic". If not specified, CSS3 transforms will be used when supported by the browser. Advantages of using CSS3 transforms are a smoother, less jarring experience during map navigation and hardware acceleration in browsers that support it. (As of v2.6)
var map = new esri.Map("map",{
extent: initExtent,
navigationMode: 'classic'
});
|
| <Number> resizeDelay | Specify a time period in milliseconds to ignore repeated calls to the resize method. Default value is 300. |
| <Number> scale | Initial map scale. If a value is not provided, the scale will be calculated based on the initial extent of the basemap. As of version 3.3 |
| <Boolean> showAttribution | Enable or disable map attribution display. The attribution is displayed at the bottom of the map next to the Esri logo. The default value is true unless you are using the compact build then the default is false. To add attribution with the compact build import the esri.dijit.Attribution module and enable showAttribution. As of v 3.1 |
| <Boolean> showInfoWindowOnClick | The default behavior is to show an InfoWindow if the Graphic has a defined InfoTemplate when the user clicks on the graphic. When true, this default behavior is honored. The default value is true. |
| <Boolean> slider | Displays a slider on the map. When false, the slider never displays. Default is true. |
| <String[]> sliderLabels | Define labels for the slider. Only valid when the sliderStyle is set to large. As of version 3.3 |
| <String> sliderOrientation | Orientation of the zoom slider. Valid values are: "vertical" or "horizontal". The default value is "vertical". As of version 3.3 |
| <String> sliderPosition | Position of the zoom slider within the map control. Valid values are: "top-left", "top-right", "bottom-left", "bottom-right". The default value is "top-left". As of version 3.3 |
| <String> sliderStyle | Defines the slider style. At version 3.3 the small slider is displayed by default. Valid values are 'small' or 'large'. |
| <Boolean> wrapAround180 | When true, supports continuous pan across the dateline. Wraparound is supported in the following cases:
- Map spatial reference is WGS84 or Web Mercator
- The tiling scheme is either the pre-9.3 ArcGIS Online (4326) tiling scheme or ArcGIS/Google Maps/ Bing tiling scheme.
- Dynamic services must be version 10 or greater.
At version 3.1 the default value is true. For versions earlier than 3.1 the default value is false. |
| <Number> zoom | Initial zoom level of the map. If a value is not provided, it will be calculated based on the initial extent of the basemap. As of version 3.3 |
Code Snippet: - In this example, a new map named "mymap" is created and will be placed inside a container named "mapDiv".
var myMap;
function init() {
//create map
myMap = new esri.Map("mapDiv");
...
}
Later in the code, the map container is referenced in the DIV id.
<div id="mapDiv" style="width:600px; height:600px; border:1px solid #000;"></div>
- In this second example, the optional extent parameter is also included in the constructor.
var myMap = new esri.Map("mapDiv", { extent: new esri.geometry.Extent
(-124.71, 31.89, -113.97, 42.63) });
- This example creates a map with no slider or pan arrows.
var myMap = new esri.Map("mapDiv", { slider:false, nav:false });
- In this example, graphics are turned off whenever the map is panned.
var myMap = new esri.Map("mapDiv", { displayGraphicsOnPan:false });
If you want the graphics turned off during a pan only for Internet Explorer, use the following constructor:
var myMap = new esri.Map("mapDiv", { displayGraphicsOnPan:! dojo.isIE });
Property Details
Reference to the attribution widget created by the map when map attribution is enabled.
Value is true when the map automatically resizes if the browser window or ContentPane widget enclosing the map is resized. Otherwise false.
Code Snippet:
function showExtent() {
var s = "";
s = "XMin: "+ myMap.extent.xmin
+" YMin: " + myMap.extent.ymin
+" XMax: " + myMap.extent.xmax
+" YMax: " + myMap.extent.ymax;
dojo.byId("info").innerHTML = s;
}
Indicates if the fade effect is enabled while zooming. Only applicable when navigationMode is set to 'css-transforms'. The default value is true.
<Boolean> force3DTransforms
When the
mapNavigation mode is set to 'css-transforms', CSS3
transforms will be used for map navigation when supported by the browser. It is recommended that you let the map determine when to enable transformations to avoid running into a known
issue with scrollbar rendering on Chrome on Windows XP.
The extent (or bounding box) of the map in geographic coordinates. Available only when the map's spatial reference is Web Mercator or Geographic (wkid 4326).
Code Snippet:
dojo.connect(map, "onExtentChange", function(){
var geo = map.geographicExtent;
console.log(geo.xmin, geo.ymin, geo.xmax, geo.ymax);
});
Provides access to the Map's GraphicsLayer. The graphics object is available to use after the Map.onLoad event.
Code Snippet:
dojo.connect(map, "onLoad", function() { ShowLocation(-81.3765, 28.54175); });
function ShowLocation(x, y)
{
var point = new esri.geometry.Point(x, y, new esri.SpatialReference({wkid:4326}));
var simpleMarkerSymbol = new esri.symbol.SimpleMarkerSymbol();
var graphic = new esri.Graphic(point, simpleMarkerSymbol);
map.graphics.add(graphic);
}
<String[]> graphicsLayerIds
Current height of the map in screen pixels. This property is read-only. The height and width of the map are normally set in the HTML DIV or other HTML element containing the map container.
Code Snippet: function getMapWidthHeight() {
alert("Width = " + myMap.width + "; Height = " + myMap.height);
}
Reference to HTML DIV or other element where the map is placed on the page. This property is set in the Map constructor.
Code Snippet:
var myMap = new esri.Map("mapDiv");
Displays the InfoWindow on a map.
<Boolean> isClickRecenter
When true, the key sequence of shift then click to recenter the map is enabled. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet:
function stopClickRecenter() {
myMap.disableClickRecenter();
dojo.byId("stopClickRecenter").value = myMap.isClickRecenter;
}
<Boolean> isDoubleClickZoom
When true, double click zoom is enabled. This allows a user to zoom and recenter the map by double clicking the mouse. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet:
dojo.byId("theDoubleClickZoom").value = myMap.isDoubleClickZoom;
<Boolean> isKeyboardNavigation
When true, keyboard navigation is enabled. This allows users to pan the keyboard using the arrow keys and to zoom using the + and - keys. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet: dojo.byId("keyboardNavigationStatus").value = myMap.isKeyboardNavigation;
When true, map panning is enabled using the mouse. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet: dojo.byId("panStatus").value = myMap.isPan;
When true, pan arrows are displayed around the edge of the map. See
Map navigation for more details.
Known Values: true | false
Default Value: false
<Boolean> isRubberBandZoom
When true, rubberband zoom is enabled. This allows users to draw a bounding box zoom area using the mouse. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet: dojo.byId("checkRubberBandZoom").value = myMap.isRubberBandZoom;
<Boolean> isScrollWheelZoom
When true, the mouse scroll wheel zoom is enabled. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet:
function stopScrollWheelZoom() {
myMap.disableScrollWheelZoom();
dojo.byId("stopScrollWheelZoom").value = myMap.isScrollWheelZoom;
}
<Boolean> isShiftDoubleClickZoom
When true, shift double click zoom is enabled. This allows a user to zoom and recenter the map by shift + double clicking the mouse. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet:
dojo.byId("theShiftDoubleClickZoom").value = myMap.isShiftDoubleClickZoom;
When true, the zoom slider is displayed on the map. See
Map navigation for more details.
Known Values: true | false
Default Value: true
Code Snippet: function getLayerProperties() {
for(var j = 0; j < map.layerIds.length; j++) {
var layer = map.getLayer(map.layerIds[j]);
alert(layer.id + ' ' + layer.opacity + ' ' + layer.visible);
}
}
After the first layer is loaded, the value is set to true.
Known Values: true | false
Indicates whether the map uses CSS3 transformations when panning and zooming. In 'css-transform' mode the map will use CSS3 transformations, if supported by the browser, to provide a smoother experience while panning and zooming the map.
Known Values: 'classic' | 'css-transforms'
This point geometry in screen coordinates represent the top-left corner of the map container. This coordinate also acts as the origin for all screen coordinates returned by
Map and
GraphicsLayer events.
The DOM node that contains the container of layers, build-in info window, logo and slider.
<Boolean> showAttribution
When true, map attribution is enabled.
If snapping is enabled on the map using
map.enableSnapping() this property provides access to the
SnappingManager. The snapping manager's
setLayerInfo method can be used to modify the target snapping layers.
Code Snippet:
var snappingManager = map.snappingManager();
Current width of the map in screen pixels. This property is read-only. The height and width of the map are normally set in the HTML DIV or other HTML element containing the map container.
Code Snippet: function getMapWidthHeight() {
alert("Width = " + myMap.width + "; Height = " + myMap.height);
}
Method Details
Adds an ESRI Layer to the map.
The return object of Layer was added at v1.4.
Input Parameters:
| <Layer> layer | Required | Layer to be added to the map. |
| <Number> index | Optional | A layer can be added at a specified index in the map. If no index is specified or the index specified is
greater than the current number of layers, the layer is automatically appended to the list of layers in the map and the index is normalized. (As of v1.3) |
Code Snippet:
var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
map.addLayer(baseMapLayer);
Adds multiple layers to a map. The array order corresponds to the layer order in the client side map. The onLayerAddResult event fires for each layer that is added. Once all the layers are added to the map the onLayersAddResult fires.
Input Parameters:
| <Layer[]> layers | Required | Layers to be added to the map. |
Code Snippet:
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
var statesLayer= new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");
map.addLayers([basemap,statesLayer]);
centerAndZoom(mapPoint,levelOrFactor)
Centers and zooms the map.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the operation is completed.
Return Value: Deferred
Input Parameters:
| <Point> mapPoint | Required | Centers the map on the specified x,y location. Starting at version 3.3, the mapPoint can be an array of longitude/latitude pairs. |
| <Number> levelOrFactor | Required | When using an ArcGISTiledMapServiceLayer, the map is zoomed to the level specified. When using a DynamicMapServiceLayer, the map is zoomed in or out by the specified factor. For example, use 0.5 to zoom in twice as far and 2.0 to zoom out twice as far. |
Code Snippet:
map.centerAndZoom(location,12);
Centers the map based on map coordinates as the center point.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the map has been re-centered to the given point.
Return Value: Deferred
Input Parameters:
| <Point> mapPoint | Required | Centers the map on the specified x,y location. Starting at version 3.3 this value can be an array of longitude/latitude pairs. |
Code Snippet:
map.centerAt(evt.mapPoint);
Destroys the map instance. After the map is destroyed it is no longer valid however you can re-use the div element of the map to create a new map instance.
Code Snippet: map.destroy();
Disallows clicking on a map to center it. See
Map navigation for more details.
Code Snippet:
function init() {
myMap = new esri.Map("mapDiv");
myMap.disableClickRecenter();
}
Disallows double clicking on a map to zoom in a level and center the map. See
Map navigation for more details.
Code Snippet:
function init() {
myMap = new esri.Map("mapDiv");
myMap.disableDoubleClickZoom();
}
disableKeyboardNavigation()
Disallows panning and zooming using the keyboard. See
Map navigation for more details.
Code Snippet:
function init() {
myMap = new esri.Map("mapDiv");
myMap.disableKeyboardNavigation();
}
Disallows all map navigation except the slider and pan arrows. See
Map navigation for more details.
Disallows panning a map using the mouse. See
Map navigation for more details.
Code Snippet:
function noPan() {
myMap.disablePan();
}
Disallows zooming in or out on a map using a bounding box. See
Map navigation for more details.
Code Snippet:
function noRubberBand() {
myMap.disableRubberBandZoom();
}
Disallows zooming in or out on a map using the mouse scroll wheel. See
Map navigation for more details.
Code Snippet:
function stopScrollWheelZoom() {
myMap.disableScrollWheelZoom();
dojo.byId("stopScrollWheelZoom").value = myMap.isScrollWheelZoom;
}
disableShiftDoubleClickZoom()
Disallows shift double clicking on a map to zoom in a level and center the map. See
Map navigation for more details.
Return Value: undefined
Code Snippet:
function init() {
myMap = new esri.Map("mapDiv");
myMap.disableShiftDoubleClickZoom();
}
Disables snapping on the map.
Code Snippet: map.disableSnapping();
Permits users to click on a map to center it. See
Map navigation for more details.
Code Snippet:
function okClickRecenter() {
myMap.enableClickRecenter();
}
Permits users to double click on a map to zoom in a level and center the map. See
Map navigation for more details.
Code Snippet:
function okDoubleClickZoom() {
myMap.enableDoubleClickZoom();
}
enableKeyboardNavigation()
Permits users to pan and zoom using the keyboard. See
Map navigation for more details.
Code Snippet:
function init() {
myMap = new esri.Map("mapDiv");
myMap.enableKeyboardNavigation();
}
Permits users to pan a map using the mouse. See
Map navigation for more details.
Code Snippet:
function panAgain() {
myMap.enablePan();
}
Permits users to zoom in or out on a map using a bounding box. See
Map navigation for more details.
Code Snippet:
function allowRubberBand() {
myMap.enableRubberBandZoom();
}
Permits users to zoom in or out on a map using the mouse scroll wheel. See
Map navigation for more details.
Code Snippet:
function allowScrollWheelZoom() {
myMap.enableScrollWheelZoom();
}
enableShiftDoubleClickZoom()
Permits users to shift double click on a map to zoom in a level and center the map. See
Map navigation for more details.
Code Snippet:
function okShiftDoubleClickZoom() {
myMap.enableShiftDoubleClickZoom();
}
enableSnapping(snapOptions?)
Enable snapping on the map when working with the Editor, Measurement widget or the Draw and Edit toolbars. If no snapOptions are provided all graphics layers, including feature layers, will be set as snap targets. Call this method after the layers are loaded.
Input Parameters:
| <Object> snapOptions | Optional |
|
<Number> tolerance
|
Specify the radius of the snapping circle in pixels. The default value is 15 pixels.
|
|
<Object>
layerInfos
|
An array of layerInfo objects that define the snapping target layers. All values are optional. If no snapping options
are set the default values will be used.
|
<Layer> layer
|
Reference to a feature or graphics layer that will be a target snapping layer. The default option
is to set all feature and graphics layers in the map to be target snapping layers.
|
|
<Boolean> snapToPoint
|
Default is true. When true snapping to points will be enabled for layers with point geometry.
|
|
<Boolean> snapToVertex
|
Default is true. When true snapping to vertices will be enabled for layers with polyline or polygon geometry.
|
|
<Boolean> snapToEdge
|
Default is true. When true snapping to edges will be enabled for layers with polyline or polygon geometry.
|
|
|
<SimpleMarkerSymbol> snapPointSymbol
|
Define a symbol for the snapping location. The default symbol is a simple marker symbol with the following properties: size:15px,color:cyan,style:STYLE_CROSS.
|
|
<Boolean> alwaysSnap
|
When true, snapping is always enabled. When false users press the snapKey to enable snapping. The default value is false.
|
|
<dojo.key> snapKey
|
When alwaysSnap is set to false use this option to define the key users press to enable snapping. The default values is the CTRL key.
|
var symbol = new esri.symbol.SimpleMarkerSymbol();
map.enableSnapping({
snapPointSymbol: symbol,
tolerance:20,
snapKey:dojo.keys.ALT
});
|
Code Snippet: map.enableSnapping();
Returns the name of the current basemap.
Return Value: String
getInfoWindowAnchor(screenCoords)
Return Value: String
Input Parameters:
| <Point> screenCoords | Required | The anchor point in screen units. |
Returns an individual layer of a map.
Input Parameters:
| <String> id | Required | ID assigned to the layer. |
Code Snippet:
//get the layer using the layer id
var incidentLayer = map.getLayer("incidentLayer");
//get the layer using the layer index
var layer = map.getLayer(map.layerIds[j]);
getLayersVisibleAtScale()
Return an array of layers visible at the current scale.
Code Snippet:
var layers = map.getLayersVisibleAtScale(map.getScale());
dojo.forEach(layers,function(layer){
console.log(layer.id);
});
Returns the maximum visible scale of the map. You cannot zoom-in beyond this scale. A value of 0 indicates that the map does not have a maximum scale constraint.
Return Value: Number
Returns the maximum zoom level of the map. You cannot zoom in beyond this value. A value of -1 indicates that the map does not have pre-defined zoom levels.
Return Value: Number
Returns the minimum visible scale of the map. You cannot zoom out beyond this scale. A value of 0 indicates that the map does not have a maximum scale constraint.
Return Value: Number
Returns the minimum zoom level of the map.You cannot zoom out beyond this value. A value of -1 indicates that the map does not have pre-defined zoom levels.
Return Value: Number
Returns the current map scale.
Return Value: Number
Code Snippet:
var currentScale = map.getScale();
console.log('Scale: ' + currentScale);
Returns the current zoom level of the map. A value of -1 indicates that the map does not have pre-defined zoom levels.
Return Value: Number
Hides the pan arrows from the map. See
Map navigation for more details.
Hides the zoom slider from the map. See
Map navigation for more details.
Pans the map south. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function south() {
myMap.panDown();
}
Pans the map west. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function west() {
myMap.panLeft();
}
Pans the map southwest. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function southWest() {
myMap.panLowerLeft();
}
Pans the map southeast. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function southEast() {
map.panLowerRight();
}
Pans the map east. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function east() {
map.panRight();
}
Pans the map north. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function north() {
map.panUp();
}
Pans the map northwest. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function northWest() {
myMap.panUpperLeft();
}
Pans the map northeast. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the pan operation is completed.
Return Value: Deferred
Code Snippet:
function northEast() {
map.panUpperRight();
}
Removes all layers from the map.
The map's extent, spatial reference, and tiling scheme if defined do not change when the layers are removed. When the next layer is added to the map, this layer is displayed at the same extent and spatial reference.
Removes the specified layer from the map.
Input Parameters:
| <Layer> layer | Required | Layer to be removed from the map.
The map's extent, spatial reference, and tiling scheme if defined do not change when the layer is removed. When the next layer is added to the map, this layer is displayed at the same extent and spatial reference. |
reorderLayer(layer,index)
Changes the layer order in the map. Note that the first layer added is always the base layer, even if its order is changed.
Input Parameters:
| <Layer> layer | Required | The layer to be moved. (As of v1.4) Beginning with version 1.4, use this parameter in place of "layerId".
In versions prior to v1.4, use "layerID" in place of "layer".
Type: <String>
Definition: The ID of the layer to be moved. This ID is assigned in Layer.id. |
| <Number> index | Required | Refers to the location for placing the layer. The bottom most layer has an index of 0. |
Code Snippet:
map.addLayer(cityLayer);
map.reorderLayer(cityLayer,1);
Repositions the map DIV on the page. This method should be used after the map DIV has been repostioned.
Resizes the map DIV. This method should be used after the map DIV has been resized.
Input Parameters:
| <Boolean> immediate | Optional | By default, the actual resize logic is delayed internally in order to throttle spurious resize events dispatched by some browsers. In cases where you explicitly call this method in a one-and-done situation, you can use the boolean immediate argument to indicate that the resize logic should be applied immediately without any delay. |
Code Snippet:
var resizeTimer;
dojo.connect(map, 'onLoad', function(theMap) {
dojo.connect(dijit.byId('map'), 'resize', function() { //resize the map if the div is resized
clearTimeout(resizeTimer);
resizeTimer = setTimeout( function() {
map.resize();
map.reposition();
}, 500);
});
});
Change the map's current basemap.
Input Parameters:
| <String> basemap | Required | A valid basemap name. Valid values are: "streets" , "satellite" , "hybrid", "topo", "gray", "oceans", "national-geographic", "osm". |
Sets the extent of the map. The extent must be in the same spatial reference as the map.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the extent change has been committed by the map.
Return Value: Deferred.
Input Parameters:
| <Extent> extent | Required | Sets the minx, miny, maxx, and maxy for a map. |
| <Boolean> fit | Optional | When true, for maps that contain tiled map service layers, you are guaranteed to have the input extent shown completely on the map. (As of v1.3) |
Code Snippet:
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
Sets the map to the specified level. Zooms to the new level based on the current map center point. Valid only with an
ArcGISTiledMapService layer.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the zoom level has been changed.
Return Value: Deferred
Input Parameters:
| <Number> level | Required | The level ID. |
Code Snippet:
map.setLevel(10);
Sets the default cursor for the map. This cursor is shown whenever the mouse is pointed over the map, except when panning by dragging the map or using SHIFT+Drag to zoom. If not set, the map uses the platform-dependent default cursor, usually an arrow.
Input Parameters:
| <String> cursor | Required | A standard CSS cursor value. Some common values include "default", "pointer", "crosshair", "text", "help", and "wait". |
Code Snippet:
map.setMapCursor("wait");
When using a url for the cursor, Firefox requires an additional, non-URL value.
map.setMapCursor("url(custom.cur),auto");
Sets the map scale to the specified value. The value must be greater than 0.
At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the map scale has been changed.
Return Value: Deferred
Input Parameters:
| <Number> scale | Required | A map scale value greater than 0. |
setTimeExtent(timeExtent)
Sets the
TimeExtent for the map. When the time extent is changed the
onTimeExtentChange event fires. Time aware layers listen for this event and update to only display content for the current time extent.
Input Parameters:
| <TimeExtent> timeExtent | Required | Set the time extent for which data is displayed on the map. |
Code Snippet:
var timeExtent = new esri.TimeExtent();
timeExtent.startTime = new Date("1/1/1989 UTC");
map.setTimeExtent(timeExtent);
setTimeSlider(timeSlider)
Set the time slider associated with the map.
Input Parameters:
| <TimeSlider> timeSlider | Required | The time slider dijit to associate with the map. |
Code Snippet: map.setTimeSlider(timeSlider);
Set the map zoom level to the given value. At version 3.4, this method returns a deferred object. You can add a callback to the deferred object and get notified after the zoom level has been changed.
Return Value: Deferred
Input Parameters:
| <Number> zoom | Required | A valid zoom level value. |
Shows the zoom slider on the map. See
Map navigation for more details.
Converts a single screen point or an array of screen points to map coordinates.
Input Parameters:
| <ScreenPoint | Point> screenPoint | Required | Converts screen coordinates to map coordinates. Starting at version 3.3, screenPoint should be an instance of ScreenPoint. |
Converts a single map point or an array of map points to screen coordinates.
Input Parameters:
| <Point> mapPoint | Required | Converts map coordinates to screen coordinates. |
Code Snippet:
var screenPoint = map.toScreen(feature.geometry.getExtent().getCenter());
Event Details
[ On Style Events | Connect Style Events ]
Fired when the map's basemap is changed.
Fires when a user single clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Code Snippet:
dojo.connect(map, "onClick", function(evt) {
map.graphics.clear();
locator.locationToAddress(evt.mapPoint, 100);
});
Fires when a user double clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
onExtentChange(extent,delta,levelChange,lod)
Fires when the extent of the map has changed.
Arguments:
| <Extent> extent | Gets the extent when after the extent has changed. |
| <Point> delta | The change in the x and y values from the previous extent. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Boolean> levelChange | When using ArcGIS Server tiled map services, the value is "true" when the user zooms to a new level. The value remains "false" during pan operations. |
| <LOD> lod | When using ArcGIS Server tiled map services, this argument returns characteristics about the level of detail. |
Code Snippet:
dojo.connect(map, "onExtentChange", function(extent){
var s = "";
s = "Xmin: "+ extent.xmin + " "
+ "Ymin: " + extent.ymin + " "
+ "Xmax: " + extent.xmax + " "
+ "Ymax: " + extent.ymax;
dojo.byId("info").innerHTML = s;
});
Fires when a keyboard key is pressed.
Arguments:
| <Object> keyEvent | The keyCode is the Unicode number representing the pressed key. See http://msdn2.microsoft.com/en-us/library/ms536938.aspx. |
Fires when a keyboard key is released.
Arguments:
| <Object> keyEvent | The keyCode is the Unicode number representing the pressed key. |
Fires any time a layer is added to the map.
Arguments:
| <Layer> layer | The layer added to the map. |
Code Snippet:
dojo.connect(map, "onLayerAdd", function() { console.log("Layer added"); });
onLayerAddResult(layer,error)
Fires after specified layer has been added to the map.
Arguments:
| <Layer> layer | The layer added to the map. |
| <Error> error | Optional argument, available when an error occurs during the update. |
Fires after the layer has been removed.
onLayerReorder(layer,index)
Fires when the map layer order has been changed.
Arguments:
| <Layer> layer | The reordered layer. |
| <Number> index | The index of the reordered layer. |
Fires when a map layer resumes drawing.
Arguments:
| <Layer> layer | The layer that has resumed drawing. |
Code Snippet:
dojo.connect(map,'onLayerSuspend',function(layer){
console.log(layer.id + ' suspended');
});
Fires when a map layer suspends drawing. A layer is considered suspended when one of the following is true:
- The layer is hidden.
- The layer is not visible at the current map scale.
- The layer is explicitly suspended by calling the
Layer.suspend method.
Arguments:
| <Layer> layer | The layer that has suspended drawing. |
Code Snippet:
dojo.connect(map,'onLayerSuspend',function(layer){
console.log(layer.id + ' suspended');
});
onLayersAddResult(results)
Fires after all layers are added to the map using the map.addLayers method.
Arguments:
| <Object[]> results | Array of result objects with the following properties
|
<Layer> layer
|
Layer added to the map.
|
|
<Boolean> success
|
True if the layer was successfully added.
|
|
<Error> error
|
Error message if the map was unable to add the layer.
|
|
Code Snippet:
dojo.connect(map, "onLayersAddResult", initEditing);
function initEditing(results) {
var layerInfos = dojo.map(results, function(result) {
return {'featureLayer':result.layer};
});
});
Fires after all the layers have been removed.
onLayersReordered(layerIds)
Fires when all the layers have been reordered.
Arguments:
| <String[]> layerIds | Gets the extent during the zoom event. |
Fires when the first or base layer has been successfully added to the map.
Arguments:
| <Map> map | Specifies the map to load. |
Code Snippet:
dojo.connect(map, "onLoad", function() {
//after map loads, connect to listen to mouse move & drag events
dojo.connect(map, "onMouseMove", showCoordinates);
dojo.connect(map, "onMouseDrag", showCoordinates);
});
Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires while the mouse is being dragged until the mouse button is released.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Code Snippet:
dojo.connect(map, "onMouseDrag", function(evt){
//get mapPoint from event and display the mouse coordinates
var mp = evt.mapPoint;
dojo.byId("info").innerHTML = mp.x + ", " + mp.y;
});
Fires when a mouse button is released and the user stops dragging the mouse.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires when a mouse button is pressed down and the user starts to drag the mouse.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires any time the mouse pointer moves over the map region. A common use for this event is to show the current x,y coordinate of the map as the user moves the mouse pointer.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Code Snippet:
dojo.connect(map, "onMouseMove", function(evt){
//get mapPoint from event and display the mouse coordinates
var mp = evt.mapPoint;
dojo.byId("info").innerHTML = mp.x + ", " + mp.y;
});
Fires when the mouse moves out of the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires when the mouse moves into the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page.
Arguments:
| <Object> event | The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint. |
Fires when the mouse wheel is scrolled.
Arguments:
| <Object> event | The returned object contains screenPoint, mapPoint, and Graphic. |
Fires during the pan process.
Arguments:
| <Extent> extent | The current extent of the map as the map is panning. |
| <Point> delta | The change in x,y values in screen units as the map is panning. |
Fires when the pan is complete.
Arguments:
| <Extent> extent | The current extent of the map as the map is panning. |
| <Point> delta | The change in x,y values in screen units from the starting screen point once the map is finished panning. |
onPanStart(extent,startPoint)
Fires when a user commences panning.
Arguments:
| <Extent> extent | The current extent of the map as the map is panning. |
| <Point> startPoint | When using a mouse, the starting point in screen units where the mouse was clicked. If the keyboard is used, the starting point is 0,0. |
Fires when the map DIV is repositioned.
Arguments:
| <Number> x | X-coordinate in screen units. |
| <Number> y | Y-coordinate in screen units. |
onResize(extent,width,height)
Fires when the map's container has been resized.
Arguments:
| <Extent> extent | The extent of the map. |
| <Number> width | The width of the map in pixels. |
| <Number> height | The height of the map in pixels. |
onTimeExtentChange(timeExtent)
Fires when the map's timeExtent property is set.
Arguments:
| <TimeExtent> timeExtent | Fires when the map's timeExtent property is changed. Time aware layers listen for this event and update to only display content for the map's specified time extent. |
Fires when the page is refreshed.
Arguments:
| <Map> map | Specified the map to unload. |
Fires after layers that are updating their content have completed. This event is often used in combination with onUpdateStart to display a "Map is busy" or "Loading..." message as visual feedback to the end-user.
Code Snippet:
dojo.connect(map,"onUpdateEnd",function(){
esri.hide(dojo.byId("status"));
});
Fires when one or more layers being updating their content. This event is often used in combination with onUpdateEnd to display a "Map is busy" or "Loading..." message as visual feedback to the end-user.
Code Snippet:
dojo.connect(map,"onUpdateEnd",function(){
esri.hide(dojo.byId("status"));
});
dojo.connect(map,"onUpdateStart",function(){
esri.show(dojo.byId("status"));
});
//Map div with loading text
<div id="map" style="position:relative; width:1024px; height:512px; border:1px solid #000;">
<span id="status" style="position: absolute; z-index: 100; right: 5px; top: 5px;">
Loading...
</span>
</div>
//CSS to style the loading text
#status {
background-color: black;
color: white;
padding: 3px;
border: solid 1px white;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
onZoom(extent,zoomFactor,anchor)
Fires during the zoom process.
Arguments:
| <Extent> extent | Gets the extent during the zoom event. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
onZoomEnd(extent,zoomFactor,anchor,level)
Fires when the zoom is complete.
Arguments:
| <Extent> extent | Gets the extent when the zoom event ends. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Number> level | Level of an ArcGISTiledMapServiceLayer after zoom is complete. |
onZoomStart(extent,zoomFactor,anchor,level)
Fires when a user commences zooming.
Arguments:
| <Extent> extent | Gets the extent when the zoom event starts. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Number> level | Level of an ArcGISTiledMapServiceLayer before the zoom commences. |
Fired when the map's basemap is changed. Should be used in favor of onBaseChange
Fires when a user single clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. Should be used in favor of onClick
Event Properties:
Fires when a user double clicks on the map using the mouse and the mouse pointer is within the map region of the HTML page. Should be used in favor of onDblClick
Event Properties:
Fires when the extent of the map has changed. Should be used in favor of onExtentChange
Event Properties:
| <Extent> extent | Gets the extent when after the extent has changed. |
| <Point> delta | The change in the x and y values from the previous extent. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Boolean> levelChange | When using ArcGIS Server tiled map services, the value is "true" when the user zooms to a new level. The value remains "false" during pan operations. |
| <LOD> lod | When using ArcGIS Server tiled map services, this argument returns characteristics about the level of detail. |
Fires when a keyboard key is pressed. Should be used in favor of onKeyDown
Event Properties:
Fires when a keyboard key is released. Should be used in favor of onKeyUp
Event Properties:
Fires any time a layer is added to the map. Should be used in favor of onLayerAdd
Event Properties:
| <Layer> layer | The layer added to the map. |
Fires after specified layer has been added to the map. Should be used in favor of
onLayerAddResult
Event Properties:
| <Layer> layer | The layer that was added to the Map |
| <Error> error | An optional parameter. The value of this parameter will a standard JavaScript Error object if an error occurred or null if the layer was added successfully. |
Fires after the layer has been removed. Should be used in favor of onLayerRemove
Event Properties:
| <Layer> layer | The removed layer. |
Fires when the map layer order has been changed. Should be used in favor of onLayerReorder
Event Properties:
| <Layer> layer | The reordered layer. |
| <Number> index | The index of the reordered layer. |
Fires when a map layer resumes drawing. Should be used in favor of onLayerResume
Event Properties:
| <Layer> layer | The layer that has resumed drawing. |
Fires after all layers are added to the map using the map.addLayers method. Should be used in favor of onLayersAddResult.
Event Properties:
| <Layer[]> layers | An array of layers added to the map. |
Fires after all the layers have been removed. Should be used in favor of onLayersRemoved
Fires when all the layers have been reordered. Should be used in favor of onLayersReordered
Event Properties:
| <Number[]> layerIds | Gets the extent during the zoom event. |
Fires when the first or base layer has been successfully added to the map. Should be used in favor of onLoad
Event Properties:
| <Map> map | Specifies the map to load. |
Fires when a mouse button is pressed down and the mouse cursor is in the map region of the HTML page. Should be used in favor of onMouseDown
Event Properties:
Fires while the mouse is being dragged until the mouse button is released. Should be used in favor of onMouseDrag
Event Properties:
Fires when a mouse button is released and the user stops dragging the mouse. Should be used in favor of onMouseDragEnd
Event Properties:
Fires when a mouse button is pressed down and the user starts to drag the mouse. Should be used in favor of onMouseDragStart
Event Properties:
Fires any time the mouse pointer moves over the map region. A common use for this event is to show the current x,y coordinate of the map as the user moves the mouse pointer. Should be used in favor of onMouseMove
Event Properties:
Fires when the mouse moves out of the map region of the HTML page. Should be used in favor of onMouseOut
Event Properties:
Fires when the mouse moves into the map region of the HTML page.. Should be used in favor of onMouseOver
Event Properties:
Fires when the mouse button is released and the mouse pointer is within the map region of the HTML page. Should be used in favor of onMouseUp
Event Properties:
Fires when the mouse wheel is scrolled. Should be used in favor of onMouseWheel
Event Properties:
Fires during the pan process. Should be used in favor of onPan
Event Properties:
| <Extent> extent | The current extent of the map as the map is panning. |
| <Point> delta | The change in x,y values in screen units as the map is panning. |
Fires when the pan is complete. Should be used in favor of onPanEnd
Event Properties:
| <Point> delta | The change in x,y values in screen units from the starting screen point once the map is finished panning. |
| <Extent> extent | The current extent of the map when panning ends. |
Fires when a user commences panning. Should be used in favor of onPanStart
Event Properties:
| <Extent> extent | The current extent of the map as the map is panning. |
Fires when the map DIV is repositioned. Should be used in favor of onReposition
Event Properties:
| <Number> x | X-coordinate in screen units. |
| <Number> y | Y-coordinate in screen units. |
Fires when the map's container has been resized. Should be used in favor of onResize
Event Properties:
| <Extent> extent | The extent of the map. |
| <Number> width | The width of the map in pixels. |
| <Number> height | The height of the map in pixels. |
Fires when the map's timeExtent property is set. Should be used in favor of onTimeExtentChange
Event Properties:
| <TimeExtent> timeExtent | Fires when the map's timeExtent property is changed. Time aware layers listen for this event and update to only display content for the map's specified time extent. |
Fires when the page is refreshed. Should be used in favor of onUnload
Event Properties:
| <Map> map | Specified the map to unload. |
Fires after layers that are updating their content have completed. This event is often used in combination with onUpdateStart to display a 'Map is busy' or 'Loading...' message as visual feedback to the end-user.. Should be used in favor of onUpdateEnd
Event Properties:
| <Error> error | An optional parameter whose value will be a JavaScript Error object if an error occurred. |
Fires when one or more layers being updating their content. This event is often used in combination with onUpdateEnd to display a 'Map is busy' or 'Loading...' message as visual feedback to the end-user. Should be used in favor of onUpdateStart
Fires during the zoom process. Should be used in favor of onZoom
Event Properties:
| <Extent> extent | Gets the extent during the zoom event. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
Fires when the zoom is complete. Should be used in favor of onZoomEnd
Event Properties:
| <Extent> extent | Gets the extent when the zoom event ends. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Number> level | Level of an ArcGISTiledMapServiceLayer after zoom is complete. |
Fires when a user commences zooming. Should be used in favor of onZoomStart
Event Properties:
| <Extent> extent | Gets the extent when the zoom event starts. |
| <Number> zoomFactor | The scale factor represents the amount as a percentage that the map zoomed in or out from the previous extent. A value of 2 means the map was zoomed in twice as far as the previous extent. A value of 0.5 means the map zoomed out twice as far as previously. |
| <Point> anchor | The location of the mouse pointer. The Point x and y values are in screen units. This point acts as an anchor point, and this part of the map stays within the map region during the zoom process. |
| <Number> level | Level of an ArcGISTiledMapServiceLayer before the zoom commences. |