Class: MapE-mail This Topic Printable Version Give Us Feedback

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.

Class hierarchy

esri.Map

Constructor

Constructor Description
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.

Properties

Property Type Description
extent Extent The current extent of the map in map units. This property is read-only.
graphics GraphicsLayer Add and remove graphics from the GraphicsLayer.
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 InfoWindow 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.
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.
spatialReference SpatialReference The spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.
width Number Current width of the map in screen pixels.

Methods

Map actions:

Method Return Value Description
addLayer(layer, index?) Layer Adds an ESRI Layer to the map.

The return object of Layer was added at v1.4.
getInfoWindowAnchor(screenCoords) String Sets an InfoWindow's anchor when calling InfoWindow.show.
getLayer(id) Layer Returns an individual layer of a map.
getLevel() Number Gets the current level of detail ID for the map. Valid only with an ArcGISTiledMapService layer.
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() none Resizes the map DIV. This method should be used after the map DIV has been resized.
setExtent(extent, fit?) none Sets the extent of the map. The extent must be in the same spatial reference as the map.
setLevel(level) none Sets the map to the specified level ID. Zooms to the new level based on the current map center point. Valid only with an ArcGISTiledMapService layer.
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.
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.

Map navigation:

Method Return Value Description
centerAndZoom(mapPoint, levelOrFactor) none Centers and zooms the map.
centerAt(mapPoint) none Recenters the map based on map coordinates as the center point.
disableClickRecenter() none Disallows clicking on a map to recenter it.
disableDoubleClickZoom() none Disallows double clicking on a map to zoom in a level and recenter the map.
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() none Disallows shift double clicking on a map to zoom in a level and recenter the map.
disbleKeyboardNavigation() none Disallows panning and zooming using the keyboard.
enableClickRecenter() none Permits users to click on a map to recenter it.
enableDoubleClickZoom() none Permits users to double click on a map to zoom in a level and recenter 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 recenter the map.
hidePanArrows() none Hides the pan arrows from the map.
hideZoomSlider() none Hides the zoom slider from the map.
panDown() none Pans the map south.
panLeft() none Pans the map west.
panLowerLeft() none Pans the map southwest.
panLowerRight() none Pans the map southeast.
panRight() none Pans the map east.
panUp() none Pans the map north.
panUpperLeft() none Pans the map northwest.
panUpperRight() none Pans the map northeast.
showPanArrows() none Shows the pan arrows on the map.
showZoomSlider() none Shows the zoom slider on the map.

Events

Event Description
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.
onLayerRemove(layer) Fires after the layer has been removed.
onLayerReorder(layer, index) Fires when the map layer order has been changed.
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, endPoint) 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, height, width) Fires when the Div containing the map has been resized.
onUnload(map) Fires when the page is refreshed.
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.
Constructor Detail

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 referencing map. This value is required.
<Object> options Optional Optional parameters. See options list.
Options:
<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);
      }
<Object> layer Layer used to initialize map. This will be the base layer. The object format is {type, url}.
<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}
        ];

        map = new esri.Map("map", {
          lods: lods
        });
<Boolean> nav Displays pan buttons on map. When false, the pan arrows never display. The default is false.
<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.
Code snippets:
  • 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 });
    
Properties Detail

<Extent> extent

The current extent of the map in map units. See Setting and using extents in a map for more information about extents.
Code snippets:
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;
}

See also:
setExtent   onExtentChange   onPan   onZoom   onZoomEnd   onZoomStart  

<GraphicsLayer> graphics

Provides access to the Map's GraphicsLayer.
See also:
showInfoWindow   Graphic   GraphicsLayer  

<String[]> graphicsLayerIds

An array of the current GraphicsLayers in the map. (As of v1.4)
See also:
layerIds  

<Number> height

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 snippets:
function getMapWidthHeight() {
  alert("Width = " + myMap.width + "; Height = " + myMap.height);
}  

<String> id

Reference to HTML DIV or other element where the map is placed on the page. This property is set in the Map constructor.
Code snippets:
myMap = new esri.Map("mapDiv");

<InfoWindow> infoWindow

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 snippets:
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 snippets:
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 snippets:
dojo.byId("keyboardNavigationStatus").value = myMap.isKeyboardNavigation;

<Boolean> isPan

When true, map panning is enabled using the mouse. See Map navigation for more details.
Known values: true | false
Default value: true
Code snippets:
dojo.byId("panStatus").value = myMap.isPan;

See also:
disablePan   enablePan  

<Boolean> isPanArrows

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
See also:
hidePanArrows   showPanArrows  

<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 snippets:
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 snippets:
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. (As of v1.2)
Known values: true | false
Default value: true
Code snippets:
dojo.byId("theShiftDoubleClickZoom").value = myMap.isShiftDoubleClickZoom;

<Boolean> isZoomSlider

When true, the zoom slider is displayed on the map. See Map navigation for more details.
Known values: true | false
Default value: true
See also:
hideZoomSlider   showZoomSlider  

<String[]> layerIds

Array of current TiledMapServiceLayers and DynamicMapServiceLayers added to the map.
Code snippets:
function getLayerProperties() {
  for(var j = 0; j < map.layerIds.length; j++) {
    var layer = map.getLayer(map.layerIds[j]);
    alert(layer.id + ' ' + layer.opacity + ' ' + layer.visibility);
  }
}

See also:
graphicsLayerIds  

<Boolean> loaded

After the first layer is loaded, the value is set to true.
Known values: true | false
See also:
onLoad   onUnload  

<Point> position

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. (As of v1.3)

<SpatialReference> spatialReference

The spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references.

<Number> width

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 snippets:
function getMapWidthHeight() {
  alert("Width = " + myMap.width + "; Height = " + myMap.height);
}  

Methods Detail

addLayer(layer, index?)

Adds an ESRI Layer to the map.

The return object of Layer was added at v1.4.
Return value: Layer
Input Parameters:
<Layer> layer Required Layer to be added to the map.
<Number> index Optional A layer can be added at a specific index in the map. If no index is specified or the index specified is greater 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)
See also:
onLayerAdd  

centerAndZoom(mapPoint, levelOrFactor)

Centers and zooms the map. (As of v1.2)
Return value: none
Input Parameters:
<Point> mapPoint Required Centers the map on the specified x,y location.
<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.

centerAt(mapPoint)

Recenters the map based on map coordinates as the center point.
Return value: none
Input Parameters:
<Point> mapPoint Required Centers the map on the specified x,y location.

disableClickRecenter()

Disallows clicking on a map to recenter it. See Map navigation for more details.
Return value: none
Code snippets:
function init() {
  myMap = new esri.Map("mapDiv");
  myMap.disableClickRecenter();
}

disableDoubleClickZoom()

Disallows double clicking on a map to zoom in a level and recenter the map. See Map navigation for more details.
Return value: none
Code snippets:
function init() {
  myMap = new esri.Map("mapDiv");
  myMap.disableDoubleClickZoom();
}

disableMapNavigation()

Disallows all map navigation except the slider and pan arrows. See Map navigation for more details.
Return value: none

disablePan()

Disallows panning a map using the mouse. See Map navigation for more details.
Return value: none
Code snippets:
function noPan() {
  myMap.disablePan();
}

See also:
enablePan   isPan  

disableRubberBandZoom()

Disallows zooming in or out on a map using a bounding box. See Map navigation for more details.
Return value: none
Code snippets:
function noRubberBand() {
  myMap.disableRubberBandZoom();
}

disableScrollWheelZoom()

Disallows zooming in or out on a map using the mouse scroll wheel. See Map navigation for more details.
Return value: none
Code snippets:
function stopScrollWheelZoom() {
  myMap.disableScrollWheelZoom();
  dojo.byId("stopScrollWheelZoom").value = myMap.isScrollWheelZoom;
}

disableShiftDoubleClickZoom()

Disallows shift double clicking on a map to zoom in a level and recenter the map. See Map navigation for more details. (As of v1.2)
Return value: none
Code snippets:
function init() {
  myMap = new esri.Map("mapDiv");
  myMap.disableShiftDoubleClickZoom();
}

disbleKeyboardNavigation()

Disallows panning and zooming using the keyboard. See Map navigation for more details.
Return value: none
Code snippets:
function init() {
  myMap = new esri.Map("mapDiv");
  myMap.disableKeyboardNavigation();
}

enableClickRecenter()

Permits users to click on a map to recenter it. See Map navigation for more details.
Return value: none
Code snippets:
function okClickRecenter() {
  myMap.enableClickRecenter();
}

enableDoubleClickZoom()

Permits users to double click on a map to zoom in a level and recenter the map. See Map navigation for more details.
Return value: none
Code snippets:
function okDoubleClickZoom() {
  myMap.enableDoubleClickZoom();
}

enableKeyboardNavigation()

Permits users to pan and zoom using the keyboard. See Map navigation for more details.
Return value: none
Code snippets:
function init() {
  myMap = new esri.Map("mapDiv");
  myMap.enableKeyboardNavigation();
}

enableMapNavigation()

Allows all map navigation. See Map navigation for more details.
Return value: none

enablePan()

Permits users to pan a map using the mouse. See Map navigation for more details.
Return value: none
Code snippets:
function panAgain() {
  myMap.enablePan();
}

See also:
isPan   disablePan  

enableRubberBandZoom()

Permits users to zoom in or out on a map using a bounding box. See Map navigation for more details.
Return value: none
Code snippets:
function allowRubberBand() {
  myMap.enableRubberBandZoom();
}

enableScrollWheelZoom()

Permits users to zoom in or out on a map using the mouse scroll wheel. See Map navigation for more details.
Return value: none
Code snippets:
function allowScrollWheelZoom() {
  myMap.enableScrollWheelZoom();
}

enableShiftDoubleClickZoom()

Permits users to shift double click on a map to zoom in a level and recenter the map. See Map navigation for more details. (As of v1.2)
Return value: none
Code snippets:
function okShiftDoubleClickZoom() {
  myMap.enableShiftDoubleClickZoom();
}

getInfoWindowAnchor(screenCoords)

Sets an InfoWindow's anchor when calling InfoWindow.show.
Return value: String
Input Parameters:
<Point> screenCoords Required The anchor point in screen units.

getLayer(id)

Returns an individual layer of a map.
Return value: Layer
Input Parameters:
<String> id Required ID assigned to the layer.

getLevel()

Gets the current level of detail ID for the map. Valid only with an ArcGISTiledMapService layer.
Return value: Number
See also:
setLevel   onLevelChanged   onLevelChanging  

hidePanArrows()

Hides the pan arrows from the map. See Map navigation for more details.
Return value: none
See also:
showPanArrows   isPanArrows  

hideZoomSlider()

Hides the zoom slider from the map. See Map navigation for more details.
Return value: none
See also:
showZoomSlider   isZoomSlider  

panDown()

Pans the map south.
Return value: none
Code snippets:
function south() {
  myMap.panDown();
}

panLeft()

Pans the map west.
Return value: none
Code snippets:
function west() {
  myMap.panLeft();
}

panLowerLeft()

Pans the map southwest.
Return value: none
Code snippets:
function southWest() {
  myMap.panLowerLeft();
}

panLowerRight()

Pans the map southeast.
Return value: none
Code snippets:
function southEast() {
  myMap.panLowerRight();
}

panRight()

Pans the map east.
Return value: none
Code snippets:
function east() {
  myMap.panRight();
}

panUp()

Pans the map north.
Return value: none
Code snippets:
function north() {
  myMap.panUp();
}

panUpperLeft()

Pans the map northwest.
Return value: none
Code snippets:
function northWest() {
  myMap.panUpperLeft();
}

panUpperRight()

Pans the map northeast.
Return value: none
Code snippets:
function northEast() {
  myMap.panUpperRight();
}

removeAllLayers()

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. (As of v1.3)
Return value: none
See also:
onLayersRemoved   onLayerRemove  

removeLayer(layer)

Removes the specified layer from the map. (As of v1.3)
Return value: none
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.
See also:
onLayerRemove  

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.
Return value: none
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.
See also:
onLayerReorder  

reposition()

Repositions the map DIV on the page. This method should be used after the map DIV has been repostioned.
Return value: none

resize()

Resizes the map DIV. This method should be used after the map DIV has been resized.
Return value: none
See also:
onResize  

setExtent(extent, fit?)

Sets the extent of the map. The extent must be in the same spatial reference as the map.
Return value: none
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)
See also:
onExtentChange   onPan   onZoom   onZoomEnd   onZoomStart   extent  

setLevel(level)

Sets the map to the specified level ID. Zooms to the new level based on the current map center point. Valid only with an ArcGISTiledMapService layer.
Return value: none
Input Parameters:
<Number> level Required The level ID.
See also:
onLevelChanged   onLevelChanging   getLevel   LOD  

setMapCursor(cursor)

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. (As of v1.5)
Return value: none
Input Parameters:
<String> cursor Required A standard CSS cursor value. Some common values include "default", "pointer", "crosshair", "text", "help", and "wait".
Code snippets:
Map.setMapCursor("wait");

showPanArrows()

Shows the pan arrows on the map. See Map navigation for more details.
Return value: none
See also:
isPanArrows   hidePanArrows  

showZoomSlider()

Shows the zoom slider on the map. See Map navigation for more details.
Return value: none
See also:
isZoomSlider   hideZoomSlider  

toMap(screenPoint)

Converts a single screen point or an array of screen points to map coordinates.
Return value: Point
Input Parameters:
<Point> screenPoint Required Converts screen coordinates to map coordinates.

toScreen(mapPoint)

Converts a single map point or an array of map points to screen coordinates.
Return value: Point
Input Parameters:
<Point> mapPoint Required Converts map coordinates to screen coordinates.

Events Detail

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.
Arguments:
<Object> event The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint.

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.
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.
See also:
setExtent   extent  

onKeyDown(keyEvent)

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.

onKeyUp(keyEvent)

Fires when a keyboard key is released.
Arguments:
<Object> keyEvent The keyCode is the Unicode number representing the pressed key.

onLayerAdd(layer)

Fires any time a layer is added to the map.
Arguments:
<Layer> layer The layer added to the map.
See also:
addLayer  

onLayerRemove(layer)

Fires after the layer has been removed. (As of v1.3)
Arguments:
<Layer> layer The removed layer.
See also:
removeLayer   removeAllLayers  

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.
See also:
reorderLayer  

onLayersRemoved()

Fires after all the layers have been removed. (As of v1.3)
See also:
removeAllLayers  

onLayersReordered(layerIds)

Fires when all the layers have been reordered. (As of v1.1)
Arguments:
<String[]> layerIds Gets the extent during the zoom event.

onLoad(map)

Fires when the first or base layer has been successfully added to the map.
Arguments:
<Map> map Specifies the map to load.
See also:
onUnload   loaded   Layer.onLoad

onMouseDown(event)

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.

onMouseDrag(event)

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.

onMouseDragEnd(event)

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.

onMouseDragStart(event)

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.

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.
Arguments:
<Object> event The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint.

onMouseOut(event)

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.

onMouseOver(event)

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.

onMouseUp(event)

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.

onMouseWheel(event)

Fires when the mouse wheel is scrolled.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onPan(extent, delta)

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.
See also:
setExtent   extent  

onPanEnd(extent, endPoint)

Fires when the pan is complete.
Arguments:
<Extent> extent The current extent of the map as the map is panning.
<Point> endPoint The ending point in screen units when panning stops.

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.

onReposition(x, y)

Fires when the map DIV is repositioned.
Arguments:
<Number> x X-coordinate in screen units.
<Number> y Y-coordinate in screen units.

onResize(extent, height, width)

Fires when the Div containing the map has been resized.
Arguments:
<Extent> extent The extent of the map.
<Number> height The height of the map in pixels.
<Number> width The width of the map in pixels.
See also:
resize  

onUnload(map)

Fires when the page is refreshed.
Arguments:
<Map> map Specified the map to unload.
See also:
loaded   onLoad  

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.
See also:
setExtent   extent  

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.
See also:
setExtent   extent  

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.
See also:
setExtent   extent