跳转到内容

@naivemap/maplibre-gl-image-layer v0.0.1-alpha.1


类: default

ImageLayer is a custom layer for MapLibre GL that renders an image with support for projection, coordinates, resampling, opacity, and masking.

示例

javascript
const imageLayer = new ImageLayer('image-layer', {
  url: 'https://example.com/image.png',
  projection: 'EPSG:4326',
  coordinates: [
   [105.289838, 32.204171], // top-left
   [110.195632, 32.204171], // top-right
   [110.195632, 28.164713], // bottom-right
   [105.289838, 28.164713] // bottom-left
 ],
});

map.addLayer(imageLayer);

参阅

实现

  • CustomLayerInterface

属性

id

id: string

A unique layer id.

实现了

maplibregl.CustomLayerInterface.id

方法

updateImage()

updateImage(option): ImageLayer

Updates the URL, the projection, the coordinates, the opacity or the resampling of the image.

参数

参数类型描述
option{ coordinates?: Coordinates; opacity?: number; projection?: string; resampling?: "linear" | "nearest"; url?: string; }Options object.
option.coordinates?CoordinatesFour geographical coordinates,
option.opacity?numberopacity of the image.
option.projection?stringProjection with EPSG code that points to the image..
option.resampling?"linear" | "nearest"The resampling/interpolation method to use for overscaling.
option.url?stringImage URL.

返回

ImageLayer


updateMask()

updateMask(mask): ImageLayer

Updates the mask property

参数

参数类型描述
maskPartial<MaskProperty>The mask property.

返回

ImageLayer