Class: Map

Map

A map object that acts as a central container for all layers and other map components.

new Map(id, spec)

Instantiate a Map object.
Name Type Description
id String The DOM element id string.
spec Object The specification object.
{
    pyramid {String} - The pyramid type for the map. Defaults to 'WebMercator'
    options: {
        numZoomLevels {integer} - The number of zoom levels.
    }
}

Methods

add(component)

Adds a component to the map.
Name Type Description
component Layer | Axis The component object.

addMarker(x, y, marker){Marker}

Creates a marker at the specified position of the map.
Name Type Description
x number The x coordinate (longitude for geospatial).
y number The y coordinate (latitude for geospatial).
marker Marker The Marker object to add.
Returns:
added marker.

getActiveBaseLayer(){BaseLayer}

Returns the currently active baselayer, or null if there isn't one.
Returns:
currently active baselayer.

getBaseLayerIndex(){integer}

Returns the currently active baselayer index.
Returns:
currently active baselayer index.

getContainerElement(){HTMLElement}

Returns the map container DOM element. This is the element to which all 'pannable' layers are attached to.
Returns:
map container div element.

getElement(){HTMLElement}

Returns the markers div element.
Returns:
marker div.

getElement(){HTMLElement}

Returns the map DOM element. This is the element to which the map object is 'attached'.
Returns:
map div element.

getHeight(){integer}

Returns the height of the entire map in pixels.
Returns:
height of the map in pixels.
Returns the tile pyramid used by the map.
Returns:
TilePyramid object.

getTheme(){String}

Returns the current theme of the map. Currently restricted to "dark" and "light".
Returns:
theme of the map.

getTileFocus(){String}

Returns the tilekey for the tile currently under the mouse.
Returns:
tilekey currently under the mouse.

getTileIterator(){TileIterator}

Returns a TileIterator object. This TileIterator contains all tiles currently visible in the map.
Returns:
TileIterator object containing all visible tiles.

getTilesInView(){Array}

Returns an array of all tilekeys currently visible in the map.
Returns:
array of tilekey strings.

getViewportElement(){HTMLElement}

Returns the map viewport DOM element. This the element that encompasses the viewable portion of the map.
Returns:
map viewport div element.

getViewportHeight(){integer}

Returns the height of the viewport in pixels.
Returns:
height of the viewport in pixels.

getViewportWidth(){integer}

Returns the width of the viewport in pixels.
Returns:
width of the viewport in pixels.

getWidth(){integer}

Returns the width of the entire map in pixels.
Returns:
width of the map in pixels.

getZoom(){integer}

Returns the maps current zoom level. Level 0 is contains the most of aggregation.
Returns:
zoom level.

off(eventType, callback)

Remove a map event callback. Supports all of the following OpenLayers.Map events:
    movestart - triggered after the start of a drag, pan, or zoom.  The event object may include a zoomChanged property that tells whether the zoom has changed.
    move - triggered after each drag, pan, or zoom
    moveend - triggered after a drag, pan, or zoom completes
    zoomstart - triggered when a zoom starts.  Listeners receive an object with center and zoom properties, for the target center and zoom level.
    zoomend - triggered after a zoom completes
    mouseover - triggered after mouseover the map
    mouseout - triggered after mouseout the map
    mousemove - triggered after mousemove the map
Name Type Description
eventType String The event type.
callback function The callback.

on(eventType, callback)

Set a map event callback. Supports all of the following OpenLayers.Map events:
    movestart - triggered after the start of a drag, pan, or zoom.  The event object may include a zoomChanged property that tells whether the zoom has changed.
    move - triggered after each drag, pan, or zoom
    moveend - triggered after a drag, pan, or zoom completes
    zoomstart - triggered when a zoom starts.  Listeners receive an object with center and zoom properties, for the target center and zoom level.
    zoomend - triggered after a zoom completes
    mouseover - triggered after mouseover the map
    mouseout - triggered after mouseout the map
    mousemove - triggered after mousemove the map
Name Type Description
eventType String The event type.
callback function The callback.

panTo(x, y)

Pans the map to a particular coordinate. The transition is animated if the region is currently in view, instantaneous if not.
Name Type Description
x number The x coordinate (longitude for geospatial).
y number The y coordinate (latitude for geospatial).

remove(component)

Removes a component from the map.
Name Type Description
component Layer | Axis The component object.

setBaseLayerIndex(index)

If multiple baselayers are attached to the map, this function is used to change the currently active one by index.
Name Type Description
index integer The index of the baselayer to switch to.

setPyramid(pyramid)

Add a pyramid to the map. All Tile iterators returned prior to this will be invalidated.
Name Type Description
pyramid AreaOfInterestTilePyramid | WebMercatorTilePyramid | Object The pyramid.

setTheme(theme)

Set the theme of the map. Currently restricted to "dark" and "light".
Name Type Description
theme String The theme identification string of the map.

trigger(eventType, event)

Trigger a map event. Supports all of the following OpenLayers.Map events:
    movestart - triggered after the start of a drag, pan, or zoom.  The event object may include a zoomChanged property that tells whether the zoom has changed.
    move - triggered after each drag, pan, or zoom
    moveend - triggered after a drag, pan, or zoom completes
    zoomstart - triggered when a zoom starts.  Listeners receive an object with center and zoom properties, for the target center and zoom level.
    zoomend - triggered after a zoom completes
    mouseover - triggered after mouseover the map
    mouseout - triggered after mouseout the map
    mousemove - triggered after mousemove the map
Name Type Description
eventType String The event type.
event Object The event object to be passed to the event.

zoomTo(x, y, zoom)

Zooms the map to a particular coordinate and zoom level. The transition is instantaneous.
Name Type Description
x number The x coordinate (longitude for geospatial).
y number The y coordinate (latitude for geospatial).
zoom integer The zoom level.

zoomToExtent(bounds)

Zooms the map to a particular bounding box. The transition is instantaneous.
Name Type Description
bounds Object The bounding box to zoom to.