Skip to content

ImageLayer

ImageLayer is a layer for displaying images with a geographic extent, extending Layer. Each image can specify its geographic extent and opacity. The gl renderer requires the image to satisfy CORS and supports pitching, while the canvas renderer does not require CORS but cannot be pitched.

js
import { Map, ImageLayer } from "maptalks";

const map = new Map("map", { center: [0, 0], zoom: 2 });

const layer = new ImageLayer("images", [
  {
    url: "http://example.com/foo.png",
    extent: [xmin, ymin, xmax, ymax],
    opacity: 1,
  },
]).addTo(map);

Constructor

js
new ImageLayer(id, images?, options?)

Parameters:

  • id String layer id.
  • images ImageItem[] (optional) array of image items, see below.
  • options Object layer options (optional).

images item

FieldTypeDescriptionDefault
urlStringimage URL
extentExtent|[xmin,ymin,xmax,ymax]geographic extent covered by the image
opacityNumberimage opacity1

options

OptionTypeDescriptionDefault
rendererStringrenderer (gl/canvas)webgl?'gl':'canvas'
crossOriginStringimage crossOrigin attributenull
alphaTestBooleandiscard pixels with alpha<=alphaTest (gl renderer)false
depthMaskBooleanwrite into the depth buffer (gl renderer)true
depthFuncStringgl depth function (never,<,=,<=,>,!=,>=,always)'<='

Member Methods

  • setImages(images: ImageItem[]): this — set images and redraw
  • getImages(): ImageItem[] — get the images

Events

Common layer events (show/hide, setopacity, add/remove, layerload, etc.) — see Layer.