maplibregl加载WMS和WMTS图层

WMS

map.addSource(`wms-source`, {
  type: "raster",
  tiles: [
    `https://map.xxx.com/geoserver/xxx/wms?service=WMS&request=GetMap&layers=图层名称&styles=&format=image/png&transparent=true&version=1.1.1&width=256&height=256&srs=EPSG:3857&bbox={bbox-epsg-3857}`,
  ],
  tileSize: 256,
});

map.addLayer({
  id: `wms-layer`,
  type: "raster",
  source: `wms-source`,
});

WMTS

map.addSource(`wmts-source`, {
  type: "raster",
  tiles: [
    `https://map.xxx.com/geoserver/gwc/service/wmts?Service=WMTS&Request=GetTile&Version=1.1.0&style&tilematrixset=EPSG:900913&Format=image/png&TileMatrix=EPSG:900913:{z}&TileCol={x}&TileRow={y}&layer=图层名称`
  ],
  tileSize: 256,
});
map.addLayer({
  id: `wmts-layer`,
  type: "raster",
  source: `wmts-source`,
});
PS:写作不易,如要转裁,请标明转载出处。
%{ comment.page.total }条评论

猜你想看

微信小程序:前端开发宝典

最近文章
工具操作
  • 内容截图
  • 全屏
登录
注册
回顶部