111
杨磊
2024-05-17 115287b451d6cb2ef3d215c1113d5e52e2f5422b
src/pages/territory/territory.vue
@@ -177,6 +177,7 @@
import L from "leaflet";
import * as echarts from "echarts";
import "echarts/extension/bmap/bmap";
import "leaflet.chinatmsproviders";
export default {
  data() {
    return {
@@ -360,55 +361,18 @@
  methods: {
    //初始化地图
    initMap() {
      // var map = L.map("map", {
      //   center: [34.26, 108.96],
      //   zoom: 4,
      //   maxZoom: 18, //最大缩放层级
      //   minZoom: 1, //最小缩放层级
      //   tileSize: 256, //切片大小
      //   attributionControl: false, // 移除右下角leaflet标识
      //   zoomControl: false, //禁用 + - 按钮
      //   maxBounds: bounds, //设置边界
      //   preferCanvas: true, //默认使用svg渲染,设置canvas渲染
      //   doubleClickZoom: false, //关闭双击缩放
      //   // dragging: false, //鼠标移动事件
      // });
      var map = L.map("map", {
        attributionControl: false,
        preferCanvas: true,
        withPopup: L.latLng(34.261, 108.96),
      }).setView([39.91667, 116.41667], 4);
      // L.tileLayer(
      //   "http://webrd01.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}"
      // ).addTo(map);
      L.tileLayer(
        "http://t0.tianditu.gov.cn/vec_c/wmts?tk=36ef7d20eba483627b043f0909c493ee"
      ).addTo(map);
      L.tileLayer
        .wmts(
          "http://t{s}.tianditu.gov.cn/vec_c/wmts?tk=36ef7d20eba483627b043f0909c493ee",
          {
            layer: "vec", // 矢量图层
            style: "default",
            tilematrixset: "c", // 缩放级别
            format: "tiles",
            attribution: "Map Data © 2023 Tencent",
            subdomains: ["0", "1", "2", "3", "4", "5", "6", "7"],
          }
        )
        .chinaProvider("TianDiTu.Normal.Map", {
          key: "76bc34ead7e30e663a4eded8aeaf5860",
          // maxZoom: 18,
          // minZoom: 5,
        })
        .addTo(map);
      let DefaultIcon1 = L.icon({