ProtectedcontrolsProtecteddisposedThe object has already been disposed.
ProtectedinteractionsKey name.
Listener.
Type.
Listener.
Add 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 :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.
ProtectedapplyProtected
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.
Clean up.
ProtecteddisposeProtected
Extension point for disposable objects.
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 the layerFilter option in options.
For polygons without a fill, only the stroke will be used for hit detection.
Polygons must have a fill style applied to ensure that pixels inside a polygon are detected.
The fill can be transparent.
Pixel.
Feature callback. The callback will be called with two arguments. The first argument is one :ol/Feature~Feature feature or :ol/render/Feature~RenderFeature render feature at the pixel, the second is the :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.
Optionaloptions: AtPixelOptions
Optional options.
Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.
Get the coordinate for a given pixel. This returns a coordinate in the map view projection.
Pixel position in the map viewport.
The coordinate for the pixel position.
Returns the coordinate in view projection for a browser event.
Event.
Coordinate.
Get all features that intersect a pixel on the viewport. For polygons without a fill, only the stroke will be used for hit detection. Polygons must have a fill style applied to ensure that pixels inside a polygon are detected. The fill can be transparent.
Pixel.
Optionaloptions: AtPixelOptions
Optional options.
The detected features or an empty array if none were found.
Get the listeners for a specified event type. Listeners are returned in the order that they will be called in.
Type.
Listeners.
Layers have sources that are still loading.
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 :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 :ol/MapBrowserEvent~MapBrowserEvent.
The map's overlay container that stops events.
The document where the map is displayed.
Get the pixel for a coordinate. This takes a coordinate in the map view projection and returns the corresponding pixel.
A map coordinate.
A pixel position in the map viewport.
Get an object of all property names and values.
Object.
Get the map renderer.
Renderer
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.
Get the view associated with this map. A view manages properties such as center and resolution.
The view that controls this map.
Browser event.
Optionaltype: string
Type.
The event to handle.
ProtectedhandleProtected
Detect if features intersect a pixel on the viewport. Layers included in the
detection can be configured through the layerFilter option.
For polygons without a fill, only the stroke will be used for hit detection.
Polygons must have a fill style applied to ensure that pixels inside a polygon are detected.
The fill can be transparent.
Pixel.
Optionaloptions: AtPixelOptions
Optional options.
Is there a feature at the given pixel?
Optionaltype: string
Type. If not provided,
true will be returned if this event target has any listeners.
Has listeners.
The object has properties.
Is rendered.
Key name.
Old value.
ProtectedonceProtectedonRedraws all text after new fonts have loaded
Key name.
Listener.
Type.
Listener.
Set the target element to render this map into.
For accessibility (focus and keyboard events for map navigation), the target element must have a
properly configured tabindex attribute. If the target element is inside a Shadow DOM, the
tabindex atribute must be set on the custom element's host element.
Optionaltarget: string | HTMLElement
The Element or id of the Element that the map is rendered in.
Set the view for this map.
The view that controls this map. It is also possible to pass a promise that resolves to options for constructing a view. This alternative allows view properties to be resolved by sources or other components that load view-related metadata.
ProtectedunProtected
Unlisten for a certain type of event.
Type.
Listener.
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 :ol/layer/Tile~TileLayer to display :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-stopeventfor controls and some overlays, and one with CSS class nameol-overlaycontainerfor other overlays (see thestopEventoption of :ol/Overlay~Overlay for the difference). The map itself is placed in a further element within the viewport.Layers are stored as a :ol/Collection~Collection in layerGroups. A top-level group is provided by the library. This is what is accessed by
getLayerGroupandsetLayerGroup. Layers entered in the options are added to this group, andaddLayerandremoveLayerchange the layer collection in the group.getLayersis a convenience function forgetLayerGroup().getLayers(). Note that :ol/layer/Group~LayerGroup is a subclass of :ol/layer/Base~BaseLayer, so layers entered in the options or added withaddLayercan 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