当前位置: 首页 > news >正文

【02】mapbox js api加载arcgis切片服务

需求:

第三方的mapbox js api加载arcgis切片服务,同时叠加在mapbox自带底图上

效果图:

形如这种地址去加载:

http://zjq2022.gis.com:8080/demo/loadmapbox.html

arcgis切片服务参考链接思路:【01】mapbox js api加载arcgis切片服务-CSDN博客

加载代码:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>mapbox 添加arcgis rest切片地图服务</title>
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <script src="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.js"></script>
    <link
      href="https://api.mapbox.com/mapbox-gl-js/v2.15.0/mapbox-gl.css"
      rel="stylesheet"
    />
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.js"></script>
    <style>
      body {
        margin: 0;
        padding: 0;
      }
      #map {
        position: absolute;
        top: 0;
        bottom: 0;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      mapboxgl.accessToken =
        "pk.eyJ1IjoibHh0aWFudGlhbiIsImEiOiJjaXd2ZjlkYnQwMTZvMnRtYWZnM2lpbHFvIn0.ef3rFZTr9psmLWahrqap2A";
      var map = new mapboxgl.Map({
        container: "map", // container id
        style: "mapbox://sprites/mapbox/streets-v8",
        center: [114.32021, 30.578322], // starting position
        zoom: 12, // starting zoom
        minZoom: 1,
        maxZoom: 18,
      });

      map.on("load", function () {
        map.addSource("arcgissource", {
          type: "raster",
          tiles: [
            "https://ncportal.geoscene.cn/server/rest/services/wuhan3857/MapServer/tile/{z}/{y}/{x}",
          ],
          tileSize: 256,
        });
        map.addLayer({
          id: "tdt-img-tiles",
          type: "raster",
          minzoom: 0,
          maxzoom: 19,
          source: "arcgissource",
        });
      });

      // // 添加argis rest 动态地图服务
      // map.on("load", function () {
      //   map.addSource("city-source", {
      //     type: "raster",
      //     tiles: [
      //       "https://whgeoscene.hygt.com/server/rest/services/全国道路/MapServer/export?dpi=96&transparent=true&format=png8&layers=&bbox={bbox-epsg-3857}&f=image&bboxSR=102100&imageSR=102100",
      //     ],
      //     // 'tiles':['http://localhost:6080/arcgis/rest/services/MyMapService/MapServer/export?dpi=96&transparent=true&format=png8&layers=&bbox={bbox-epsg-3857}&f=image&bboxSR=3857&imageSR=3857'],
      //     // "tiles": ['http://221.239.0.144:6080/arcgis/rest/services/oceanname_vector/MapServer/export?bbox={bbox-epsg-3857}&f=image&transparent=true&format=png8&bboxSR=102100&imageSR=102100'],
      //     tileSize: 256,
      //   });
      //   map.addLayer({
      //     id: "sity-layer",
      //     type: "raster",
      //     source: "city-source",
      //   });

      // });
    </script>
  </body>
</html>

相关文章:

  • Python数据分析案例33——新闻文本主题多分类(Transformer, 组合模型) 模型保存
  • 如何避免知识付费小程序平台的陷阱?搭建平台的最佳实践
  • Webpack5入门到原理12:处理 Html 资源
  • linux上面hadoop配置集群
  • 现阶段Python和Java哪个更吃香?
  • Ubuntu使用QtCreator + CMake 开发C/C++程序
  • 克魔助手工具详解、数据包抓取分析、使用教程
  • 【备战蓝桥杯】图的遍历问题
  • C++后端笔记
  • MetaGPT-打卡-day2,MetaGPT框架组件学习
  • CSS 浮动 定位
  • 算法训练营第五十二天|300.最长递增子序列 674. 最长连续递增序列 718. 最长重复子数组
  • 软件工程研究生后期总结
  • 【Vue技巧】vue3中不支持.sync语法糖的解决方案
  • Flink启动Yarn Session报错:Couldn‘t deploy Yarn session cluster
  • 免费chartGPT网站汇总
  • Android aar包集成与报错
  • [python]裁剪文件夹中所有pdf文档并按名称保存到指定的文件夹
  • 写点东西《什么是网络抓取?》
  • 音乐人声分离工具:极简的人声和背景音乐分离工具
  • 125%→10%、24%税率暂停90天,对美关税开始调整
  • 最新研究:新型合成小分子可“精准杀伤”癌细胞
  • 内塔尼亚胡:以军将在未来几天“全力进入”加沙
  • 专访|茸主:杀回UFC,只为给自己一个交代
  • 河南信阳拟发文严控预售许可条件:新出让土地开发的商品房一律现房销售
  • “远践”项目启动公益生态圈,上海青少年公益力量蓬勃生长