shuishen
2021-11-15 ce09b2988ff0b033ae584d67a95d8bb2bf74b98a
地图更改
1 files modified
49 ■■■■■ changed files
src/components/map/main.vue 49 ●●●●● patch | view | raw | blame | history
src/components/map/main.vue
@@ -7,7 +7,8 @@
 * @LastEditTime: 2021-04-24 11:59:43
-->
<template>
  <div id="track_map" style="height: 100%"></div>
    <div id="track_map"
         style="height: 100%"></div>
</template>
<script>
import "ol/ol.css";
@@ -94,7 +95,48 @@
  mounted() {
    //建立地图
    this.createmap(2); //1为本地
    // this.createmap(); //空或其他是外网
        // 正式服务器上使用
        this.ol2d = new OlMap({
            layers: [
                new OlLayerTile({//矢量地图
                    source: new WMTS({
                        url: "http://47.49.21.207:7001/PGIS_S_TileMapServer/Maps/YX",
                        layer: "JX14YGJCIMGL7_L14",
                        style: "default",
                        matrixSet: "JX14YGJCIMGL7_L14",
                        format: "image/png",
                        wrapX: true,
                        tileGrid: new WMTSTileGrid({
                            origin: getTopLeft(projectionExtent),
                            //resolutions: res.slice(0, 15),
                            resolutions: resolutions,
                            matrixIds: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
                        })
                    }),
                })
            ],
            // 注意地图控件的写法
            controls: defaults().extend([
                new FullScreen(),
                new ScaleLine(),
                // new MousePosition(),
                new Rotate(),
                new Attribution()
            ]),
            target: 'track_map',
            view: new OlView({
                center: [115.85883507433789, 28.708432053474827],
                projection: projection,
                zoom: 11,
                maxZoom: 15,
                minZoom: 1
            })
        })
    this.parentParameter();
@@ -149,6 +191,8 @@
            projection: "EPSG:4326",
          }),
        });
            } else {
        var projection = getProjection("EPSG:4326");
        var projectionExtent = projection.getExtent();
        var size = getWidth(projectionExtent) / 256;
@@ -157,7 +201,6 @@
          //计算比例尺
          resolutions[z] = size / Math.pow(2, z);
        }
      } else {
        // 正式服务器上使用
        this.ol2d = new OlMap({
          layers: [