美文网首页
11.newLayer系列-VectorTileLayer

11.newLayer系列-VectorTileLayer

作者: xueyueshuai | 来源:发表于2023-08-22 14:08 被阅读0次

WMTS 服务

import "ol/ol.css";
import WMTSTileGrid from 'ol/tilegrid/WMTS'
import {Projection} from 'ol/proj'
import VectorTileLayer from 'ol/layer/VectorTile';
import VectorTileSource from "ol/source/VectorTile";
import {GeoJSON} from 'ol/format'

let xysGetVectorTileLayer = () => {

  let layer = 'one:base-old'
  let baseUrl = 'http://43.143.xxx.xxx:8083/geoserver/gwc/service/wmts'


  let urlConstruct = () => {
    let url = baseUrl + '?';
    for (let param in params) {
      url = url + param + '=' + params[param] + '&';
    }
    url = url.slice(0, -1);
    return url;
  }

  let gridsetName = 'EPSG:4326';

  let params = {
    'REQUEST': 'GetTile',
    'SERVICE': 'WMTS',
    'VERSION': '1.0.0',
    'LAYER': layer,
    'STYLE': '',
    'TILEMATRIX': gridsetName + ':{z}',
    'TILEMATRIXSET': gridsetName,
    'FORMAT': 'application/json;type=geojson',
    'TILECOL': '{x}',
    'TILEROW': '{y}'
  };

  //切片名
  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 projection = new Projection({
    code: 'EPSG:4326',
    units: 'degrees',
    axisOrientation: 'neu'
  });

  return new VectorTileLayer({
    source: new VectorTileSource({
      url: urlConstruct(),
      format: new GeoJSON({}),    //切片格式
      projection: projection,
      tileGrid: new WMTSTileGrid({
        tileSize: [256, 256],
        extent: [-180.0, -90.0, 180.0, 90.0],  //范围
        origin: [-180.0, 90.0],   //切片原点
        resolutions: resolutions,   //分辨率
        matrixIds: matrixIds    //层级标识列表,与地图级数保持一致
      })
    }),
    wrapX: false,
  });
// let views = new View({
//   center: [117.28, 31.86],
//   projection: projection,
//   zoom: 6,
//   resolutions: resolutions,
//   extent: [-180.0, -90.0, 180.0, 90.0]
// });

}

export default xysGetVectorTileLayer

相关文章

  • 亲手做过的美食们

    早餐系列一 系列二 午餐系列一 系列二 系列三....

  • 包包

    小清新学院风系列 古风系列 黑色系列 粉色系列 白色系列 可爱系列 学院风系列 双肩包系列

  • 2018我的彩铅

    多肉植物系列 美食系列 动物系列 美发系列 人物系列 其他

  • 有趣的图

    浣熊系列 猫系列 小猫与纸窗帘系列 迷人的狗狗系列 人物系列 仙女系列 娃娃与鸽子树系列 陌生的动物系列 南风包包...

  • 文章系列初稿

    育儿系列 家庭主妇系列 职场观察系列 小说系列 生活感悟情感系列 美图系列 读书读后感及总结系列 婆媳关系系列 专...

  • 鞋子2

    黑色系列 粉色系列 卡其色系列 白色系列 黑色系列 杏色系列 其他色系

  • 写作自检清单

    博客搭建系列Markdown教程Git教程系列基础教学系列linux 命令教学系列配置系列太基础教程系列广告系列诸...

  • 淑女系列

    冬装系列 毛呢大衣系列 短外套系列,秋 夏装系列

  • linux符号整理-正则整理

    引号符号系列: 重定向符号系列: 特殊符号系列: 通配符系列匹配文件内容信息 正则符号系列: 扩展正则系列:

  • 华硕主板哪个系列好?华硕主板系列介绍

    主板系列 目前华硕主板主要分为ROG MAXIMUS系列、TUF系列、ROG STRIX系列、PRIME系列,它们...

网友评论

      本文标题:11.newLayer系列-VectorTileLayer

      本文链接:https://www.haomeiwen.com/subject/ftykpdtx.html