Class: WMSTileLayer

WMSTileLayer

Used to display [WMS]{https://en.wikipedia.org/wiki/Web_Map_Service} services as tile layers on the map. Extends TileLayer. Implemented based on Leaflet's TileLayer.WMS.

new WMSTileLayer(id, optionsopt) [source]

var layer = new maptalks.WMSTileLayer('wms', {
    'urlTemplate' : 'https://demo.boundlessgeo.com/geoserver/ows',
    'crs' : 'EPSG:3857',
    'layers' : 'ne:ne',
    'styles' : '',
    'version' : '1.3.0',
    'format': 'image/png',
    'transparent' : true,
    'uppercase' : true
});
Parameter Type Default Description
id String | Number tile layer's id
options opt Object null options defined in WMSTileLayer
Extends:
Fires:

Members

  • (constant) options

  • Properties:
    Name Type Description
    options Object TileLayer's options
    Properties
    Name Type Default Description
    service opt String WMS WMS Service
    layers String Comma-separated list of WMS layers to show.
    styles opt String '' Comma-separated list of WMS styles.
    format opt String image/jpeg WMS image format (use `'image/png'` for layers with transparency).
    transparent opt String false Version of the WMS service to use
    version opt String 1.1.1 size of the tile image
    crs opt String null Coordinate Reference System to use for the WMS requests, defaults to map CRS. Don't change this if you're not sure what it means.
    uppercase opt Boolean false If `true`, WMS request parameter keys will be uppercase.
    detectRetina opt Boolean false If `true` and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
    urlTemplate String | function url templates
    subdomains opt Array.<String> | Array.<Number> null subdomains to replace '{s}' in urlTemplate
    spatialReference opt Object null TileLayer's spatial reference
    tileSize opt Array.<Number> [256, 256] size of the tile image, [width, height]
    offset opt Array.<Number> | function [0, 0] overall tile offset, [dx, dy], useful for tile sources from difference coordinate systems, e.g. (wgs84 and gcj02)
    tileSystem opt Array.<Number> null tile system number arrays
    maxAvailableZoom opt Number null Maximum zoom level for which tiles are available. Data from tiles at the maxAvailableZoom are used when displaying the map at higher zoom levels.
    repeatWorld opt Boolean true tiles will be loaded repeatedly outside the world.
    background opt Boolean true whether to draw a background during or after interacting, true by default
    placeholder opt Boolean | function false a placeholder image to replace loading tile, can be a function with a parameter of the tile canvas
    fragmentShader opt String null custom fragment shader, replace the default fragment shader
    crossOrigin opt String null tile image's corssOrigin
    fadeAnimation opt Boolean true fade animation when loading tiles
    fadeDuration opt Number 167 fading animation duration in ms, default is 167 (10 frames)
    debug opt Boolean false if set to true, tiles will have borders and a title of its coordinates.
    renderer opt String gl TileLayer's renderer, canvas or gl. gl tiles requires image CORS that canvas doesn't. canvas tiles can't pitch.
    maxCacheSize opt Number 256 maximum number of tiles to cache
    cascadeTiles opt Boolean true draw cascaded tiles of different zooms to reduce tiles
    zoomOffset opt Number 0 offset from map's zoom to tile's zoom
    tileRetryCount opt Number 0 retry count of tiles
    errorUrl opt String null image to replace when encountering error on loading tile image
    customTags opt Object null custom tag values in urlTemplate, e.g. { foo: 'bar' } for http://path/to/{z}/{x}/{y}?foo={foo}
    decodeImageInWorker opt Boolean false decode image in worker, for better performance if the server support
    token opt String null token to replace {token} in template http://foo/bar/{z}/{x}/{y}?token={token}
    fetchOptions opt Object object fetch params,such as fetchOptions: { 'headers': { 'accept': '' } }, about accept value more info https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values
    awareOfTerrain opt Boolean true if the tile layer is aware of terrain.
    bufferPixel opt Number 0.5 tile buffer size,the unit is pixel
    depthMask opt Number true mask to decide whether to write depth buffer
    attribution opt String null the attribution of this layer, you can specify company or other information of this layer.
    minZoom opt Number null the minimum zoom to display the layer, set to -1 to unlimit it.
    maxZoom opt Number null 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
    hitDetect opt Boolean true Whether to enable hit detection for layers for cursor styles on this map, disable it to improve performance.
    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
    collisionScope opt String layer layer's collision scope: layer or map
    Overrides:
    Source:

    Methods

  • toJSON() [source]

  • Export the WMSTileLayer's json.
    It can be used to reproduce the instance by fromJSON method
    Returns:
    Object: layer's JSON
  • (inherited) forceReload() [source]

  • force Reload tilelayer. Note that this method will clear all cached tiles and reload them. It shouldn't be called frequently for performance reason.
    Returns:
    TileLayer: this
  • (inherited) getTileSize() [source]

  • Get tile size of the tile layer
    Returns:
    Size:
  • (inherited) _getScreenSpaceError() [source]

  • Compute tile's SSE from Cesium 与cesium不同的是,我们用boundingVolume顶面的四个顶点中的最小值作为distanceToCamera

  • (inherited) _getCascadeTiles(z) [source]

  • Get tiles at zoom z (or current zoom)
    Parameter Type Description
    z Number zoom
    Returns:
    Array.<Object>: tile descriptors
  • (inherited) getTileUrl(x, y, z) [source]

  • Get tile's url
    Parameter Type Description
    x Number
    y Number
    z Number
    Returns:
    String: url
  • (inherited) clear() [source]

  • Clear the layer
    Returns:
    TileLayer: this
  • (inherited) getSpatialReference() [source]

  • Get tilelayer's spatial reference.
    Returns:
    SpatialReference: spatial reference
  • (inherited) getMaxAvailableZoom() [source]

  • Get tileLayer's max available zoom, either options['maxAvailableZoom'] or spatialReference's maxZoom
    Returns:
    Number:
  • (inherited) getPolygonOffsetCount() [source]

  • Get layer's polygonOffset count
    Returns:
    Number:
  • (inherited) getPolygonOffset() [source]

  • Get layer's base polygon offset
    Returns:
    Number:
  • (inherited) setPolygonOffset(offset) [source]

  • Set layer's base polygon offset, called by GroupGLLayer
    Parameter Type Description
    offset Number polygon offset
    Returns:
    TileLayer:
  • (inherited) load() [source]

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

  • (inherited) getId() [source]

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

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

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

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

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

  • Get Layer's minZoom to display
    Returns:
    Number:
  • (inherited) getMaxZoom() [source]

  • Get Layer's maxZoom to display
    Returns:
    Number:
  • (inherited) getOpacity() [source]

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

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

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

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

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

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

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

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

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

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

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

  • Get the mask geometry of the layer
    Returns:
    Geometry:
  • (inherited) 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
  • (inherited) removeMask() [source]

  • Remove the mask
    Returns:
    Layer: this
  • (protected) (inherited) 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.
  • (inherited) isLoaded() [source]

  • Whether the layer is loaded
    Returns:
    Boolean:
  • (inherited) getCollisionIndex() [source]

  • Get layer's collision index
    Returns:
    CollisionIndex:
  • (inherited) clearCollisionIndex() [source]

  • Clear layer's collision index. Will ignore if collisionScope is not layer

  • (inherited) 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
  • (inherited) 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
  • (inherited) 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
  • (inherited) 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
  • (inherited) 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
  • (inherited) 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:
  • (inherited) getListeningEvents() [source]

  • Get all the listening event types
    Mixes From:
    Returns:
    Array.<String>: events
  • (inherited) 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
  • (inherited) 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
  • (inherited) 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:

  • (inherited) 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
  • (inherited) getJSONType() [source]

  • Get object's JSON Type
    Mixes From:
    Returns:
    String:
  • (inherited) 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
  • (inherited) 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.
    Returns:
    Class: this
  • (inherited) setOptions(options) [source]

  • Merges options with the default options of the object.
    Parameter Type Description
    options Object options to set
    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
    Returns:
    Class: this
  • (inherited) onConfig() [source]

  • Default callback when config is called

    Events

  • (inherited) clear [source]

  • clear event, fired when tile layer is cleared.
    Properties:
    Name Type Description
    type String clear
    target TileLayer tile layer
    Overrides:
    Source:

  • (inherited) 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
    Overrides:
    Source:

  • (inherited) setzindex [source]

  • setzindex event.
    Properties:
    Name Type Description
    type String setzindex
    target Layer the layer fires the event
    zIndex Number value of the zIndex
    Overrides:
    Source:

  • (inherited) setopacity [source]

  • setopacity event.
    Properties:
    Name Type Description
    type String setopacity
    target Layer the layer fires the event
    opacity Number value of the opacity
    Overrides:
    Source:

  • (inherited) show [source]

  • show event.
    Properties:
    Name Type Description
    type String show
    target Layer the layer fires the event
    Overrides:
    Source:

  • (inherited) hide [source]

  • hide event.
    Properties:
    Name Type Description
    type String hide
    target Layer the layer fires the event
    Overrides:
    Source:

  • (inherited) renderercreate [source]

  • renderercreate event, fired when renderer is created.
    Properties:
    Name Type Description
    type String renderercreate
    target Layer the layer fires the event
    renderer Any renderer of the layer
    Overrides:
    Source:

  • (inherited) visiblechange [source]

  • visiblechange event.
    Properties:
    Name Type Description
    type String visiblechange
    target Layer the layer fires the event
    visible Boolean value of visible
    Overrides:
    Source:

  • (inherited) resourceload [source]

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

  • (inherited) 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
    Overrides:
    Source:

  • (inherited) 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
    Overrides:
    Source:

  • (inherited) renderend [source]

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