PilotGaea 2D O'view
    正在準備搜尋索引...

    類別 Map

    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:

    var map = new ol.Map({
      view: new ol.View({
        center: [0, 0],
        zoom: 1
      }),
      layers: [
        new ol.layer.Tile({
          source: new ol.source.OSM()
        })
      ],
      target: 'map'
    });
    

    The above snippet creates a map using a ol.layer.Tile to display ol.source.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 (see getViewport()), and then two further elements within the viewport: one with CSS class name ol-overlaycontainer-stopevent for controls and some overlays, and one with CSS class name ol-overlaycontainer for other overlays (see the stopEvent option of ol.Overlay for the difference). The map itself is placed in a further element within the viewport, either DOM or Canvas, depending on the renderer.

    Layers are stored as a ol.Collection in layerGroups. A top-level group is provided by the library. This is what is accessed by getLayerGroup and setLayerGroup. Layers entered in the options are added to this group, and addLayer and removeLayer change the layer collection in the group. getLayers is a convenience function for getLayerGroup().getLayers(). Note that ol.layer.Group is a subclass of ol.layer.Base, so layers entered in the options or added with addLayer can be groups, which can contain further groups, and so on.

    Map options.

    ol.MapBrowserEvent

    ol.MapEvent

    ol.render.Event#postcompose

    ol.render.Event#precompose

    stable

    層級 (查看層級一覽)

    索引

    方法

    • Removes an event listener using the key returned by on() or once().

      參數

      • key: Object | Object[]

        The key returned by on() or once() (or an array of keys).

      回傳 void

      stable

    • Add the given control to the map.

      參數

      回傳 void

      stable

    • Add the given interaction to the map.

      參數

      回傳 void

      stable

    • 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 on ol.Collection.

      參數

      回傳 void

      stable

    • Add the given overlay to the map.

      參數

      回傳 void

      stable

    • Add functions to be called before rendering. This can be used for attaching animations before updating the map's view. The ol.animation namespace provides several static methods for creating prerender functions.

      參數

      回傳 void

    • 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.

      類型參數

      • T

      參數

      • pixel: Pixel

        Pixel.

      • callback: (feature: ol.Feature | ol.render.Feature, layer: Layer) => T

        Feature callback. The callback will be called with two arguments. The first argument is one feature or render feature at the pixel, the second is the layer of the feature and will be null for unmanaged layers. To stop detection, callback functions can return a truthy value.

      • 可選opt_layerFilter: (layer: Layer) => boolean

        Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested.

      回傳 T

      Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.

      stable

    • 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.

      類型參數

      • S
      • T
      • U

      參數

      • pixel: Pixel

        Pixel.

      • callback: (layer: Layer, color: Color) => T

        Layer callback. This callback will recieve two arguments: first is the layer, second argument is ol.Color and will be null for layer types that do not currently support this argument. To stop detection callback functions can return a truthy value.

      • 可選opt_this: S

        Value to use as this when executing callback.

      • 可選opt_layerFilter: (layer: Layer) => boolean

        Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested.

      • 可選opt_this2: U

        Value to use as this when executing layerFilter.

      回傳 T

      Callback result, i.e. the return value of last callback execution, or the first truthy callback return value.

      stable

    • Detect if features intersect a pixel on the viewport. Layers included in the detection can be configured through opt_layerFilter.

      參數

      • pixel: Pixel

        Pixel.

      • 可選opt_layerFilter: (layer: Layer) => boolean

        Layer filter function. The filter function will receive one argument, the layer-candidate and it should return a boolean value. Only layers which are visible and for which this function returns true will be tested for features. By default, all visible layers will be tested.

      回傳 boolean

      Is there a feature at the given pixel?

    • Returns the geographical coordinate for a browser event.

      參數

      • event: Event

        Event.

      回傳 Coordinate

      Coordinate.

      stable

    • Returns the map pixel position for a browser event relative to the viewport.

      參數

      • event: Event

        Event.

      回傳 Pixel

      Pixel.

      stable

    • 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.

      回傳 string | Element

      The Element or id of the Element that the map is rendered in.

      stable

    • Get the DOM element into which this map is rendered. In contrast to getTarget this method always return an Element, or null if the map has no target.

      回傳 Element

      The element that the map is rendered in.

    • Get the coordinate for a given pixel. This returns a coordinate in the map view projection.

      參數

      • pixel: Pixel

        Pixel position in the map viewport.

      回傳 Coordinate

      The coordinate for the pixel position.

      stable

    • Get the map controls. Modifying this collection changes the controls associated with the map.

      回傳 ol.Collection<Control>

      Controls.

      stable

    • Get the map overlays. Modifying this collection changes the overlays associated with the map.

      回傳 ol.Collection<Overlay>

      Overlays.

      stable

    • 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.

      參數

      • id: string | number

        Overlay identifier.

      回傳 Overlay

      Overlay.

    • Get the map interactions. Modifying this collection changes the interactions associated with the map.

      Interactions are used for e.g. pan, zoom and rotate.

      回傳 ol.Collection<Interaction>

      Interactions.

      stable

    • Get the layergroup associated with this map.

      回傳 Group

      A layer group containing the layers in this map.

      stable

    • Get the collection of layers associated with this map.

      回傳 ol.Collection<Base>

      Layers.

      stable

    • Get the pixel for a coordinate. This takes a coordinate in the map view projection and returns the corresponding pixel.

      參數

      回傳 Pixel

      A pixel position in the map viewport.

      stable

    • Get the size of this map.

      回傳 Size

      The size in pixels of the map in the DOM.

      stable

    • Get the view associated with this map. A view manages properties such as center and resolution.

      回傳 View

      The view that controls this map.

      stable

    • Get the element that serves as the map viewport.

      回傳 Element

      Viewport.

      stable

    • Requests an immediate render in a synchronous manner.

      回傳 void

      stable

    • Request a map rendering (at the next animation frame).

      回傳 void

      stable

    • Remove the given control from the map.

      參數

      回傳 Control

      The removed control (or undefined if the control was not found).

      stable

    • Remove the given interaction from the map.

      參數

      回傳 Interaction

      The removed interaction (or undefined if the interaction was not found).

      stable

    • Removes the given layer from the map.

      參數

      回傳 Base

      The removed layer (or undefined if the layer was not found).

      stable

    • Remove the given overlay from the map.

      參數

      回傳 Overlay

      The removed overlay (or undefined if the overlay was not found).

      stable

    • Sets the layergroup of this map.

      參數

      • layerGroup: Group

        A layer group containing the layers in this map.

      回傳 void

      stable

    • Set the size of this map.

      參數

      • size: Size

        The size in pixels of the map in the DOM.

      回傳 void

    • Set the target element to render this map into.

      參數

      • target: string | Element

        The Element or id of the Element that the map is rendered in.

      回傳 void

      stable

    • Set the view for this map.

      參數

      • view: View

        The view that controls this map.

      回傳 void

      stable

    • Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport.

      回傳 void

      stable

    • Gets a value.

      參數

      • key: string

        Key name.

      回傳 any

      Value.

      stable

    • Get a list of object property names.

      回傳 string[]

      List of property names.

      stable

    • Get an object of all property names and values.

      回傳 { [k: string]: any }

      Object.

      stable

    • Sets a value.

      參數

      • key: string

        Key name.

      • value: any

        Value.

      • 可選opt_silent: boolean

        Update without triggering an event.

      回傳 void

      stable

    • 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: { [k: string]: any }

        Values.

      • 可選opt_silent: boolean

        Update without triggering an event.

      回傳 void

      stable

    • Unsets a property.

      參數

      • key: string

        Key name.

      • 可選opt_silent: boolean

        Unset without triggering an event.

      回傳 void

      stable

    • Increases the revision counter and dispatches a 'change' event.

      回傳 void

    • 函數

      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.

      參數

      回傳 void

    • Get the version number for this object. Each time the object is modified, its version number will be incremented.

      回傳 number

      Revision.

    • Listen for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object to use as this in listener.

      回傳 Object | Object[]

      Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

      stable

    • Listen once for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object to use as this in listener.

      回傳 Object | Object[]

      Unique key for the listener. If called with an array of event types as the first argument, the return will be an array of keys.

      stable

    • Unlisten for a certain type of event.

      參數

      • type: string | string[]

        The event type or array of event types.

      • listener: Function

        The listener function.

      • 可選opt_this: Object

        The object which was used as this by the listener.

      回傳 void

      stable

    • 函數

      Removes an event listener using the key returned by on() or once(). Note that using the ol.Observable.unByKey static function is to be preferred.

      參數

      • key: Object | Object[]

        The key returned by on() or once() (or an array of keys).

      回傳 void

      stable

    構造函數

    • 參數

      回傳 Map

      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:

      var map = new ol.Map({
        view: new ol.View({
          center: [0, 0],
          zoom: 1
        }),
        layers: [
          new ol.layer.Tile({
            source: new ol.source.OSM()
          })
        ],
        target: 'map'
      });
      

      The above snippet creates a map using a ol.layer.Tile to display ol.source.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 (see getViewport()), and then two further elements within the viewport: one with CSS class name ol-overlaycontainer-stopevent for controls and some overlays, and one with CSS class name ol-overlaycontainer for other overlays (see the stopEvent option of ol.Overlay for the difference). The map itself is placed in a further element within the viewport, either DOM or Canvas, depending on the renderer.

      Layers are stored as a ol.Collection in layerGroups. A top-level group is provided by the library. This is what is accessed by getLayerGroup and setLayerGroup. Layers entered in the options are added to this group, and addLayer and removeLayer change the layer collection in the group. getLayers is a convenience function for getLayerGroup().getLayers(). Note that ol.layer.Group is a subclass of ol.layer.Base, so layers entered in the options or added with addLayer can be groups, which can contain further groups, and so on.

      ol.MapBrowserEvent

      ol.MapEvent

      ol.render.Event#postcompose

      ol.render.Event#precompose

      stable