关于arcgis:arcgis加载wtms数据

42次阅读

共计 818 个字符,预计需要花费 3 分钟才能阅读完成。

这是 wtms 服务地址,肯定要记得加 tile

http://***.***.***.***:6080/arcgis/rest/services/***/***/MapServer/tile/
export const CustomWMTS = async (val) => {
  let BaseTileLayer = await arcgisPackage.BaseTileLayer;
  let Request = await arcgisPackage.Request;
  let TDT = await BaseTileLayer.createSubclass({
    properties: {
      urlTemplate: null,
      layerType:'wmts'
    },
    getTileUrl: function (level, row, col) {
      let url =val + level + '/' + row + '/' + col
      return url;
    },
    fetchTile: function (level, row, col) {let url = this.getTileUrl(level, row, col);
      return Request(url, {responseType: "image",}).then((response) =>{
        let image = response.data;
        let width = this.tileInfo.size[0];
        let height = this.tileInfo.size[0];

        let canvas = document.createElement("canvas");
        let context = canvas.getContext("2d");
        canvas.width = width;
        canvas.height = height;

        context.drawImage(image, 0, 0, width, height);

        return canvas;
      })
    },
  });
  let layer = await new TDT();
  return layer
}

正文完
 0