ol加载arcgis server发布的wmts服务地图

 that.layer.tiandituImgLayer = new ImageLayer({
        title: 'generalMap',
        source: new ImageArcGISRest({
          ratio: 1,
          params: {},
          url: 'http://218.2.231.245/mapjs2/rest/services/MapJS/js_yxdt_latest/MapServer',
        }),
        // zIndex: 1,
        visible: true
      });
import "ol/ol.css";
import {Map, View} from "ol";
import {Tile} from 'ol/layer'
import {OSM, WMTS} from 'ol/source';
import WMTSTileGrid from 'ol/tilegrid/WMTS'
import {Projection} from 'ol/proj'
initWmts() {
      let that = this;
      //可以出来结果
      let matrixIds = ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2', 'EPSG:4326:3',
        'EPSG:4326:4', 'EPSG:4326:5', 'EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8',
        'EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13',
        'EPSG:4326:14', 'EPSG:4326:15', 'EPSG:4326:16', 'EPSG:4326:17', 'EPSG:4326:18',
        'EPSG:4326:19', 'EPSG:4326:20', 'EPSG:4326:21'];
      //分辨率
      let resolutions = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 6.866455078125E-4, 3.4332275390625E-4, 1.71661376953125E-4, 8.58306884765625E-5, 4.291534423828125E-5, 2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6, 2.682209014892578E-6, 1.341104507446289E-6, 6.705522537231445E-7, 3.3527612686157227E-7];

      //切片策略
      let tileGrid = new WMTSTileGrid({
        tileSize: [256, 256],
        extent: [-180.0, -90.0, 180.0, 90.0],  //范围
        origin: [-180.0, 90.0],   //切片原点
        resolutions: resolutions,   //分辨率
        matrixIds: matrixIds    //层级标识列表,与地图级数保持一致
      });
      //设置地图投影
      let projection = new Projection({
        code: 'EPSG:4326',
        units: 'degrees',
        axisOrientation: 'neu'
      });

      let tileSource = new WMTS({
        url: 'http://218.2.231.242:18081/geoserver/gwc/service/wmts',
        layer: "division:city_line",
        format: "image/png",
        matrixSet: "EPSG:4326",
        projection: projection,
        tileGrid: tileGrid
      });

      let tileLayer = new Tile({
        opacity: 0.7,    //透明度
        source: tileSource,
        wrapX: false,
      });
      that.map.addLayer(tileLayer);
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小仙有礼了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值