Protected
controlsProtected
disposedThe object has already been disposed.
Protected
interactionsAdd the given interaction to the map. If you want to add an interaction
at another point of the collection use getInteractions()
and the methods
available on module:ol/Collection~Collection. This can be used to
stop the event propagation from the handleEvent function. The interactions
get to handle the events in the reverse order of this collection.
Interaction to add.
Add the given overlay to the map.
Overlay.
Protected
applyProtected
Apply any properties from another object without triggering events.
The source object.
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 type
property.
Event object.
false
if anyone called preventDefault on the
event object or if any of the listeners returned false.
Protected
disposeDetect 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 the layerFilter
option in options
.
Pixel.
Feature callback. The callback will be called with two arguments. The first argument is one module:ol/Feature~Feature feature or module:ol/render/Feature~RenderFeature render feature at the pixel, the second is the module:ol/layer/Layer~Layer layer of the feature and will be null for unmanaged layers. To stop detection, callback functions can return a truthy value.
Optional
options: AtPixelOptionsOptional options.
Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.
Get the map controls. Modifying this collection changes the controls associated with the map.
Controls.
Get the map interactions. Modifying this collection changes the interactions associated with the map.
Interactions are used for e.g. pan, zoom and rotate.
Interactions.
Get the collection of layers associated with this map.
Layers.
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'
or 2
.
Overlay identifier.
Overlay.
Get the element that serves as the container for overlays. Elements added to this container will let mousedown and touchstart events through to the map, so clicks and gestures on an overlay will trigger module:ol/MapBrowserEvent~MapBrowserEvent events.
The map's overlay container.
Get the element that serves as a container for overlays that don't allow event propagation. Elements added to this container won't let mousedown and touchstart events through to the map, so clicks and gestures on an overlay don't trigger any module:ol/MapBrowserEvent~MapBrowserEvent.
The map's overlay container that stops events.
Get the map overlays. Modifying this collection changes the overlays associated with the map.
Overlays.
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.
The Element or id of the Element that the map is rendered in.
The event to handle.
Protected
handleDetect if features intersect a pixel on the viewport. Layers included in the
detection can be configured through the layerFilter
option.
Pixel.
Optional
options: AtPixelOptionsOptional options.
Is there a feature at the given pixel?
Protected
onceProtected
onClear any existing layers and add layers to the map.
The layers to be added to the map.
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).
Values.
Optional
silent: booleanUpdate without triggering an event.
Protected
un
Classdesc
The map is the core component of OpenLayers. For a map to render, a view, one or more layers, and a target container are needed:
The above snippet creates a map using a module:ol/layer/Tile~TileLayer to display module:ol/source/OSM~OSM OSM data and render it to a DOM element with the id
map
.The constructor places a viewport container (with CSS class name
ol-viewport
) in the target element (seegetViewport()
), and then two further elements within the viewport: one with CSS class nameol-overlaycontainer-stopevent
for controls and some overlays, and one with CSS class nameol-overlaycontainer
for other overlays (see thestopEvent
option of module:ol/Overlay~Overlay for the difference). The map itself is placed in a further element within the viewport.Layers are stored as a module:ol/Collection~Collection in layerGroups. A top-level group is provided by the library. This is what is accessed by
getLayerGroup
andsetLayerGroup
. Layers entered in the options are added to this group, andaddLayer
andremoveLayer
change the layer collection in the group.getLayers
is a convenience function forgetLayerGroup().getLayers()
. Note that module:ol/layer/Group~LayerGroup is a subclass of module:ol/layer/Base~BaseLayer, so layers entered in the options or added withaddLayer
can be groups, which can contain further groups, and so on.Fires
import("./MapBrowserEvent.js").MapBrowserEvent
Fires
import("./MapEvent.js").MapEvent
Fires
import("./render/Event.js").default#precompose
Fires
import("./render/Event.js").default#postcompose
Fires
import("./render/Event.js").default#rendercomplete
Api