Parcourir la source

一张图:
1. 缩放自适应修改;
2. 影像地址修改;
3. 地图抖动修改;
4. 要素图层样式修改;

chengbeibei il y a 10 mois
Parent
commit
01b3a2e681
2 fichiers modifiés avec 25 ajouts et 7 suppressions
  1. 23 5
      src/components/OneMap/BasicMap.vue
  2. 2 2
      src/components/OneMap/widgets/BaseMap.vue

+ 23 - 5
src/components/OneMap/BasicMap.vue

@@ -8,7 +8,9 @@
       </div>
     </div>
     <div style="flex: 1">
-      <div ref="basicMap" class="basicMap" id="basicMap" :style="{ height: height }">
+      <!-- 原来的,F11不能自适应 -->
+<!--      <div ref="basicMap" class="basicMap" id="basicMap" :style="{ height: height }">-->
+      <div ref="basicMap" class="basicMap" id="basicMap" :style="{ height: '100%' }">
         <tool-bar v-model="isToolBar" ref="toolBar" :tools="mapTools" :v-if="toolsLoaded"></tool-bar>
         <locate-by-geoinfo ref="locateByGeoinfo"></locate-by-geoinfo>
         <base-map v-if="enableTianditu" ref="baseMap" :wkid="this.wkid"></base-map>
@@ -387,7 +389,7 @@ export default {
         // 定义一个范围变量
         let fullextent = null
         // 设置鼠标滚轮事件
-        view.on('mouse-wheel', (e) => {
+        /*view.on('mouse-wheel', (e) => { // 此处事件会导致地图抖动,于2024-6-19注释掉
           // 延迟获取范围的函数
           window.setTimeout(() => {
             // 获取操作图层的范围
@@ -397,7 +399,7 @@ export default {
               nview.extent = fullextent
             })
           }, 1)
-        })
+        })*/
         // 设置鼠标拖拽事件
         view.on('drag', (e) => {
           // 获取操作图层的范围
@@ -431,6 +433,7 @@ export default {
     // 载入图层到layers
     _loadLayer: function (layerItem, esriMap) {
       let layer = null
+      let layer_opacity = null
       switch (layerItem.servicetype) {
         case 'DynamicLayer': {
           layer = new MapImageLayer({
@@ -499,12 +502,26 @@ export default {
         }
         /*sugb 20240530 wms服务*/
         case 'WFSLayer': {
-          layer = new WFSLayer({
+          // 更新要素样式
+          layer = new WMSLayer({
+            id: layerItem.id,
+            url: layerItem.url,
+            title: layerItem.alias,
+            name: layerItem.name,
+            style: layerItem.style,
+            sublayers: [{
+              name: layerItem.name
+            }],
+            visible: layerItem.visible,
+          })
+
+          layer_opacity = new WFSLayer({
             id: layerItem.id,
             url: layerItem.url,
             title: layerItem.alias,
             name: layerItem.name,
             style: layerItem.style,
+            opacity: 0,
             popupTemplate: {
               overwriteActions: true,
               outFields: ['*'],
@@ -543,13 +560,14 @@ export default {
         if (this.layerNum == this.layerCount) {
           this.$emit('layer-loadAll', true)
           this.mapView.extent = this.initExtent
-          this.initBaseLayer()
+          // this.initBaseLayer() // 此处会导致进入地图页面后影像消失,所以注释掉
         }
       })
       if (parseInt(layerItem.zIndex)) {
         esriMap.add(layer, parseInt(layerItem.zIndex))
       } else {
         esriMap.add(layer)
+        esriMap.add(layer_opacity)
       }
     },
 

+ 2 - 2
src/components/OneMap/widgets/BaseMap.vue

@@ -63,8 +63,8 @@ export default {
         },
       });
       let tmsLayer = new TMSLayer({
-        urlTemplate: "/sd_dom/sd/{z}/{x}/{y}.png"
-        //urlTemplate: "http://218.59.194.82:12682/sd_dom/sd/{z}/{x}/{y}.png"
+        // urlTemplate: "/sd_dom/sd/{z}/{x}/{y}.png"
+        urlTemplate: "http://218.59.194.82:12682/sd_dom/sd/{z}/{x}/{y}.png"
       });
 
       this.localMap=new Basemap({