new ol.Map(options)
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| options | Map options. 
 | ||||||||||||||||||||||||||||||||||||||||
Fires:
- 
            changeexperimental - Triggered when the revision counter is increased.
- 
            change:layerGroup(ol.ObjectEvent)
- 
            change:size(ol.ObjectEvent)
- 
            change:target(ol.ObjectEvent)
- 
            change:view(ol.ObjectEvent)
- 
            click(ol.MapBrowserEvent) - A click with no dragging. A double click will fire two of this.
- 
            dblclick(ol.MapBrowserEvent) - A true double click, with no dragging.
- 
            moveend(ol.MapEvent) - Triggered after the map is moved.
- 
            pointerdrag(ol.MapBrowserEvent) experimental - Triggered when a pointer is dragged.
- 
            pointermove(ol.MapBrowserEvent) - Triggered when a pointer is moved. Note that on touch devices this is triggered when the map is panned, so is not the same as mousemove.
- 
            postcompose(ol.render.Event) experimental
- 
            postrender(ol.MapEvent) experimental - Triggered after a map frame is rendered.
- 
            precompose(ol.render.Event) experimental
- 
            propertychange(ol.ObjectEvent) - Triggered when a property is changed.
- 
            singleclick(ol.MapBrowserEvent) - A true single click with no dragging and no double click. Note that this event is delayed by 250 ms to ensure that it is not a double click.
Extends
Observable Properties
| Name | Type | Settable | ol.ObjectEvent type | Description | 
|---|---|---|---|---|
| layerGroup | ol.layer.Group | yes | change:layergroup | A layer group containing the layers in this map. | 
| size | ol.Size | undefined | yes | change:size | The size in pixels of the map in the DOM. | 
| target | Element | string | undefined | yes | change:target | The Element or id of the Element that the map is rendered in. | 
| view | ol.View | yes | change:view | The view that controls this map. | 
Methods
- 
    addControl(control)src/ol/map.js, line 500
- 
    
    Add the given control to the map. Name Type Description controlol.control.Control Control. 
- 
    addInteraction(interaction)src/ol/map.js, line 512
- 
    
    Add the given interaction to the map. Name Type Description interactionol.interaction.Interaction Interaction to add. 
- 
    addLayer(layer)src/ol/map.js, line 527
- 
    
    Adds the given layer to the top of this map. If you want to add a layer elsewhere in the stack, use getLayers()and the methods available onol.Collection.Name Type Description layerol.layer.Base Layer. 
- 
    addOverlay(overlay)src/ol/map.js, line 538
- 
    
    Add the given overlay to the map. Name Type Description overlayol.Overlay Overlay. 
- 
    beforeRender(var_args) experimentalsrc/ol/map.js, line 566
- 
    
    Add functions to be called before rendering. This can be used for attaching animations before updating the map's view. The ol.animationnamespace provides several static methods for creating prerender functions.Name Type Description var_argsol.PreRenderFunction Any number of pre-render functions. 
- 
    changed() inherited experimentalsrc/ol/observable.js, line 50
- 
    
    Increases the revision counter and dispatches a 'change' event. 
- 
    dispatchEvent(event) inherited experimentalsrc/ol/observable.js, line 72
- 
    
    Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a typeproperty.Name Type Description eventgoog.events.EventLike Event object. 
- 
    forEachFeatureAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2){T|undefined}src/ol/map.js, line 617
- 
    
    Detect features that intersect a pixel on the viewport, and execute a callback with each intersecting feature. Layers included in the detection can be configured through opt_layerFilter.Name Type Description pixelol.Pixel Pixel. callbackfunction Feature callback. The callback will be called with two arguments. The first argument is one featureorrender featureat the pixel, the second is thelayerof the feature and will be null for unmanaged layers. To stop detection, callback functions can return a truthy value.thisS Value to use as thiswhen executingcallback.layerFilterfunction Layer filter function. The filter function will receive one argument, the layer-candidateand it should return a boolean value. Only layers which are visible and for which this function returnstruewill be tested for features. By default, all visible layers will be tested.this2U Value to use as thiswhen executinglayerFilter.Returns:Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.
 
- 
    forEachLayerAtPixel(pixel, callback, opt_this, opt_layerFilter, opt_this2){T|undefined}src/ol/map.js, line 654
- 
    
    Detect layers that have a color value at a pixel on the viewport, and execute a callback with each matching layer. Layers included in the detection can be configured through opt_layerFilter.Name Type Description pixelol.Pixel Pixel. callbackfunction Layer callback. Will receive one argument, the layerthat contains the color pixel. To stop detection, callback functions can return a truthy value.thisS Value to use as thiswhen executingcallback.layerFilterfunction Layer filter function. The filter function will receive one argument, the layer-candidateand it should return a boolean value. Only layers which are visible and for which this function returnstruewill be tested for features. By default, all visible layers will be tested.this2U Value to use as thiswhen executinglayerFilter.Returns:Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.
 
- 
    get(key){*} inheritedsrc/ol/object.js, line 147
- 
    
    Gets a value. Name Type Description keystring Key name. Returns:Value.
 
- 
    getControls(){ol.Collection.<ol.control.Control>}src/ol/map.js, line 771
- 
    
    Get the map controls. Modifying this collection changes the controls associated with the map. Returns:Controls.
 
- 
    getCoordinateFromPixel(pixel){ol.Coordinate}src/ol/map.js, line 754
- 
    
    Get the coordinate for a given pixel. This returns a coordinate in the map view projection. Name Type Description pixelol.Pixel Pixel position in the map viewport. Returns:The coordinate for the pixel position.
 
- 
    getEventCoordinate(event){ol.Coordinate}src/ol/map.js, line 702
- 
    
    Returns the geographical coordinate for a browser event. Name Type Description eventEvent Event. Returns:Coordinate.
 
- 
    getEventPixel(event){ol.Pixel}src/ol/map.js, line 713
- 
    
    Returns the map pixel position for a browser event relative to the viewport. Name Type Description eventEvent Event. Returns:Pixel.
 
- 
    getInteractions(){ol.Collection.<ol.interaction.Interaction>}src/ol/map.js, line 809
- 
    
    Get the map interactions. Modifying this collection changes the interactions associated with the map. Interactions are used for e.g. pan, zoom and rotate. Returns:Interactions.
 
- 
    getKeys(){Array.<string>} inheritedsrc/ol/object.js, line 161
- 
    
    Get a list of object property names. Returns:List of property names.
 
- 
    getLayerGroup(){ol.layer.Group}src/ol/map.js, line 820
- 
    
    Get the layergroup associated with this map. Returns:A layer group containing the layers in this map.
 
- 
    getLayers(){ol.Collection.<ol.layer.Base>}src/ol/map.js, line 830
- 
    
    Get the collection of layers associated with this map. Returns:Layers.
 
- 
    getOverlayById(id){ol.Overlay} experimentalsrc/ol/map.js, line 795
- 
    
    Get an overlay by its identifier (the value returned by overlay.getId()). Note that the index treats string and numeric identifiers as the same. So map.getOverlayById(2)will return an overlay with id'2'or2.Name Type Description idstring | number Overlay identifier. Returns:Overlay.
 
- 
    getOverlays(){ol.Collection.<ol.Overlay>}src/ol/map.js, line 782
- 
    
    Get the map overlays. Modifying this collection changes the overlays associated with the map. Returns:Overlays.
 
- 
    getPixelFromCoordinate(coordinate){ol.Pixel}src/ol/map.js, line 843
- 
    
    Get the pixel for a coordinate. This takes a coordinate in the map view projection and returns the corresponding pixel. Name Type Description coordinateol.Coordinate A map coordinate. Returns:A pixel position in the map viewport.
 
- 
    getProperties(){Object.<string, *>} inheritedsrc/ol/object.js, line 171
- 
    
    Get an object of all property names and values. Returns:Object.
 
- 
    getRevision(){number} inherited experimentalsrc/ol/observable.js, line 81
- 
    
    Get the version number for this object. Each time the object is modified, its version number will be incremented. Returns:Revision.
 
- 
    getSize(){ol.Size|undefined}src/ol/map.js, line 869
- 
    
    Get the size of this map. Returns:The size in pixels of the map in the DOM.
 
- 
    getTarget(){Element|string|undefined}src/ol/map.js, line 728
- 
    
    Get the target in which this map is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that. Returns:The Element or id of the Element that the map is rendered in.
 
- 
    getTargetElement(){Element} experimentalsrc/ol/map.js, line 741
- 
    
    Get the DOM element into which this map is rendered. In contrast to getTargetthis method always return anElement, ornullif the map has no target.Returns:The element that the map is rendered in.
 
- 
    getView(){ol.View}src/ol/map.js, line 881
- 
    
    Get the view associated with this map. A view manages properties such as center and resolution. Returns:The view that controls this map.
 
- 
    getViewport(){Element}src/ol/map.js, line 891
- 
    
    Get the element that serves as the map viewport. Returns:Viewport.
 
- 
    hasFeatureAtPixel(pixel, opt_layerFilter, opt_this){boolean} experimentalsrc/ol/map.js, line 683
- 
    
    Detect if features intersect a pixel on the viewport. Layers included in the detection can be configured through opt_layerFilter.Name Type Description pixelol.Pixel Pixel. layerFilterfunction Layer filter function. The filter function will receive one argument, the layer-candidateand it should return a boolean value. Only layers which are visible and for which this function returnstruewill be tested for features. By default, all visible layers will be tested.thisU Value to use as thiswhen executinglayerFilter.Returns:Is there a feature at the given pixel?
 
- 
    on(type, listener, opt_this){goog.events.Key} inheritedsrc/ol/observable.js, line 94
- 
    
    Listen for a certain type of event. Name Type Description typestring | Array.<string> The event type or array of event types. listenerfunction The listener function. thisObject The object to use as thisinlistener.Returns:Unique key for the listener.
 
- 
    once(type, listener, opt_this){goog.events.Key} inheritedsrc/ol/observable.js, line 107
- 
    
    Listen once for a certain type of event. Name Type Description typestring | Array.<string> The event type or array of event types. listenerfunction The listener function. thisObject The object to use as thisinlistener.Returns:Unique key for the listener.
 
- 
    removeControl(control){ol.control.Control|undefined}src/ol/map.js, line 1229
- 
    
    Remove the given control from the map. Name Type Description controlol.control.Control Control. Returns:The removed control (or undefined if the control was not found).
 
- 
    removeInteraction(interaction){ol.interaction.Interaction|undefined}src/ol/map.js, line 1243
- 
    
    Remove the given interaction from the map. Name Type Description interactionol.interaction.Interaction Interaction to remove. Returns:The removed interaction (or undefined if the interaction was not found).
 
- 
    removeLayer(layer){ol.layer.Base|undefined}src/ol/map.js, line 1258
- 
    
    Removes the given layer from the map. Name Type Description layerol.layer.Base Layer. Returns:The removed layer (or undefined if the layer was not found).
 
- 
    removeOverlay(overlay){ol.Overlay|undefined}src/ol/map.js, line 1271
- 
    
    Remove the given overlay from the map. Name Type Description overlayol.Overlay Overlay. Returns:The removed overlay (or undefined if the overlay was not found).
 
- 
    render()src/ol/map.js, line 1215
- 
    
    Request a map rendering (at the next animation frame). 
- 
    renderSync()src/ol/map.js, line 1206
- 
    
    Requests an immediate render in a synchronous manner. 
- 
    set(key, value, opt_silent) inheritedsrc/ol/object.js, line 201
- 
    
    Sets a value. Name Type Description keystring Key name. value* Value. silentboolean Update without triggering an event. 
- 
    setLayerGroup(layerGroup)src/ol/map.js, line 1375
- 
    
    Sets the layergroup of this map. Name Type Description layerGroupol.layer.Group A layer group containing the layers in this map. 
- 
    setProperties(values, opt_silent) inheritedsrc/ol/object.js, line 221
- 
    
    Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties). Name Type Description valuesObject.<string, *> Values. silentboolean Update without triggering an event. 
- 
    setSize(size) experimentalsrc/ol/map.js, line 1386
- 
    
    Set the size of this map. Name Type Description sizeol.Size | undefined The size in pixels of the map in the DOM. 
- 
    setTarget(target)src/ol/map.js, line 1398
- 
    
    Set the target element to render this map into. Name Type Description targetElement | string | undefined The Element or id of the Element that the map is rendered in. 
- 
    setView(view)src/ol/map.js, line 1409
- 
    
    Set the view for this map. Name Type Description viewol.View The view that controls this map. 
- 
    un(type, listener, opt_this) inheritedsrc/ol/observable.js, line 120
- 
    
    Unlisten for a certain type of event. Name Type Description typestring | Array.<string> The event type or array of event types. listenerfunction The listener function. thisObject The object which was used as thisby thelistener.
- 
    unByKey(key) inheritedsrc/ol/observable.js, line 133
- 
    
    Removes an event listener using the key returned by on()oronce(). Note that using theol.Observable.unByKeystatic function is to be preferred.Name Type Description keygoog.events.Key The key returned by on()oronce().
- 
    unset(key, opt_silent) inheritedsrc/ol/object.js, line 235
- 
    
    Unsets a property. Name Type Description keystring Key name. silentboolean Unset without triggering an event. 
- 
    updateSize()src/ol/map.js, line 1429
- 
    
    Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport. 
 OpenLayers 3
 OpenLayers 3