Class: Layer

Layer

Base class for all the layers, defines common methods that all the layer classes share.
It is abstract and not intended to be instantiated.

Members

  • (constant) options

  • Properties:
    Name Type Default Description
    options opt Object null base options of layer.
    Properties
    Name Type Default Description
    attribution opt String null the attribution of this layer, you can specify company or other information of this layer.
    minZoom opt Number -1 the minimum zoom to display the layer, set to -1 to unlimit it.
    maxZoom opt Number -1 the maximum zoom to display the layer, set to -1 to unlimit it.
    visible opt Boolean true whether to display the layer.
    opacity opt Number 1 opacity of the layer, from 0 to 1.
    zIndex opt Number z index of the layer
    renderer opt String canvas renderer type, "canvas" in default.
    globalCompositeOperation opt String null (Only for layer rendered with CanvasRenderer) globalCompositeOperation of layer's canvas 2d context.
    debugOutline opt String '#0f0' debug outline's color.
    cssFilter opt String null css filter apply to canvas context's filter
    forceRenderOnMoving opt Boolean false force to render layer when map is moving
    forceRenderOnZooming opt Boolean false force to render layer when map is zooming
    forceRenderOnRotating opt Boolean false force to render layer when map is Rotating
    Source:

    Static Methods

  • (static) fromJSON(layerJSON) [source]

  • Reproduce a Layer from layer's JSON.
    Parameter Type Description
    layerJSON Object layer's JSON
    Returns:
    Layer:

    Methods

  • load() [source]

  • load the tile layer, can't be overrided by sub-classes

  • getId() [source]

  • Get the layer id
    Returns:
    String: id
  • setId(id) [source]

  • Set a new id to the layer
    Parameter Type Description
    id String new layer id
    Fires:
    Returns:
    Layer: this
  • addTo(map) [source]

  • Adds itself to a map.
    Parameter Type Description
    map Map map added to
    Returns:
    Layer: this
  • setZIndex(zIndex) [source]

  • Set a z-index to the layer
    Parameter Type Description
    zIndex Number layer's z-index
    Returns:
    Layer: this
  • getZIndex() [source]

  • Get the layer's z-index
    Returns:
    Number:
  • getOpacity() [source]

  • Get layer's opacity
    Returns:
    Number:
  • setOpacity(opacity) [source]

  • Set opacity to the layer
    Parameter Type Description
    opacity Number layer's opacity
    Returns:
    Layer: this
  • (protected) isCanvasRender() [source]

  • If the layer is rendered by HTML5 Canvas.
    Returns:
    Boolean:
  • getMap() [source]

  • Get the map that the layer added to
    Returns:
    Map:
  • getProjection() [source]

  • Get projection of layer's map
    Returns:
    Object:
  • bringToFront() [source]

  • Brings the layer to the top of all the layers
    Returns:
    Layer: this
  • bringToBack() [source]

  • Brings the layer under the bottom of all the layers
    Returns:
    Layer: this
  • show() [source]

  • Show the layer
    Returns:
    Layer: this
  • hide() [source]

  • Hide the layer
    Returns:
    Layer: this
  • isVisible() [source]

  • Whether the layer is visible now.
    Returns:
    Boolean:
  • remove() [source]

  • Remove itself from the map added to.
    Returns:
    Layer: this
  • getMask() [source]

  • Get the mask geometry of the layer
    Returns:
    Geometry:
  • setMask(mask) [source]

  • Set a mask geometry on the layer, only the area in the mask will be displayed.
    Parameter Type Description
    mask Geometry mask geometry, can only be a Marker with vector symbol, a Polygon or a MultiPolygon
    Returns:
    Layer: this
  • removeMask() [source]

  • Remove the mask
    Returns:
    Layer: this
  • (protected) onLoad() [source]

  • Prepare Layer's loading, this is a method intended to be overrided by subclasses.
    Returns:
    Boolean: true to continue loading, false to cease.
  • isLoaded() [source]

  • Whether the layer is loaded
    Returns:
    Boolean:
  • (mixin) on(eventsOn, handler, contextopt) [source]

  • Register a handler function to be called whenever this event is fired.
    foo.on('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventsOn String event types to register, seperated by space if more than one.
    handler function handler function to be called
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    Any: this
  • (mixin) addEventListener(eventTypes, handler, contextopt) [source]

  • Alias for on
    Parameter Type Default Description
    eventTypes String event types to register, seperated by space if more than one.
    handler function handler function to be called
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) once(eventTypes, handler, contextopt) [source]

  • Same as on, except the listener will only get fired once and then removed.
    foo.once('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventTypes String event types to register, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) off(eventsOff, handler, contextopt) [source]

  • Unregister the event handler for the specified event types.
    foo.off('mousedown mousemove mouseup', onMouseEvent, foo);
    Parameter Type Default Description
    eventsOff String event types to unregister, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) removeEventListener(eventTypes, handler, contextopt) [source]

  • Alias for off
    Parameter Type Default Description
    eventTypes String event types to unregister, seperated by space if more than one.
    handler function listener handler
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    : this
  • (mixin) listens(eventType, hanlderopt, contextopt) [source]

  • Returns listener's count registered for the event type.
    Parameter Type Default Description
    eventType String an event type
    hanlder opt function null listener function
    context opt Object null the context of the handler
    Mixes From:
    Returns:
    Number:
  • (mixin) copyEventListeners(target) [source]

  • Copy all the event listener to the target object
    Parameter Type Description
    target Object target object to copy to.
    Mixes From:
    Returns:
    : this
  • (mixin) fire(eventType, param) [source]

  • Fire an event, causing all handlers for that event name to run.
    Parameter Type Description
    eventType String an event type to fire
    param Object parameters for the listener function.
    Mixes From:
    Returns:
    : this
  • (mixin) registerJSONType(type) [source]

  • It is a static method.
    Register layer for JSON serialization and assign a JSON type.
    Parameter Type Description
    type String JSON type
    Mixes From:

  • (mixin) getJSONClass(type) [source]

  • It is a static method.
    Get class of input JSON type
    Parameter Type Description
    type String JSON type
    Mixes From:
    Returns:
    Class: Class
  • (mixin) getJSONType() [source]

  • Get object's JSON Type
    Mixes From:
    Returns:
    String:
  • (mixin) registerRenderer(name, clazz) [source]

  • Register a renderer class with the given name.
    Parameter Type Description
    name String renderer's register key
    clazz function renderer's class, a function (not necessarily a Class).
    Mixes From:
    Returns:
    *: this
  • (mixin) getRendererClass(name) [source]

  • Get the registered renderer class by the given name
    Parameter Type Description
    name String renderer's register key
    Mixes From:
    Returns:
    function: renderer's class
  • (inherited) callInitHooks() [source]

  • Visit and call all the init hooks defined on Class and its parents.
    Inherited From:
    Returns:
    Class: this
  • (inherited) setOptions(options) [source]

  • Merges options with the default options of the object.
    Parameter Type Description
    options Object options to set
    Inherited From:
    Returns:
    Class: this
  • (inherited) config(conf) [source]

  • 1. Return object's options if no parameter is provided.
    2. update an option and enable/disable the handler if a handler with the same name existed.
    // Get marker's options;
    var options = marker.config();
    // Set map's option "draggable" to false and disable map's draggable handler.
    map.config('draggable', false);
    // You can update more than one options like this:
    map.config({
        'scrollWheelZoom' : false,
        'doubleClickZoom' : false
    });
    Parameter Type Description
    conf Object config to update
    Inherited From:
    Returns:
    Class: this
  • (inherited) onConfig() [source]

  • Default callback when config is called

    Events

  • idchange [source]

  • idchange event.
    Properties:
    Name Type Description
    type String idchange
    target Layer the layer fires the event
    old String value of the old id
    new String value of the new id
    Source:

  • resourceload [source]

  • resourceload event, fired when external resources of the layer complete loading.
    Properties:
    Name Type Description
    type String resourceload
    target Layer layer
    Source:

  • canvascreate [source]

  • canvascreate event, fired when canvas created.
    Properties:
    Name Type Description
    type String canvascreate
    target Layer layer
    context CanvasRenderingContext2D canvas's context
    gl WebGLRenderingContext2D canvas's webgl context
    Source:

  • renderstart [source]

  • renderstart event, fired when layer starts to render.
    Properties:
    Name Type Description
    type String renderstart
    target Layer layer
    context CanvasRenderingContext2D canvas's context
    Source:

  • renderend [source]

  • renderend event, fired when layer ends rendering.
    Properties:
    Name Type Description
    type String renderend
    target Layer layer
    context CanvasRenderingContext2D canvas's context
    Source:

  • layerload [source]

  • layerload event, fired when layer is loaded.
    Properties:
    Name Type Description
    type String layerload
    target Layer layer
    Source: