Forráskód Böngészése

封装地图初始视角方法

sbj 1 éve
szülő
commit
8c0c29c28e
3 módosított fájl, 28 hozzáadás és 44 törlés
  1. 18 0
      src/utils/map/Common.js
  2. 7 30
      src/utils/map/WaterPassenger.js
  3. 3 14
      src/views/map/Index.vue

+ 18 - 0
src/utils/map/Common.js

@@ -0,0 +1,18 @@
+/**
+ * 地图中公共组件方法
+ */
+import { fullExtent, clearMap, calculation, changeMap, setCamera,
+    layerControl, layerQuery, addGraphic, draw, getDrawGeometry,
+    addBoats, setBoatHistory, playBoatHistory,
+    getMapScale
+} from '@/utils/map/ArcgisUtil'
+
+export function setCenter() {
+    setCamera({
+        x:2667,
+        y:463,
+        z:3800,
+        heading:100,
+        tilt:0
+    })
+}

+ 7 - 30
src/utils/map/WaterPassenger.js

@@ -8,6 +8,7 @@ import {
 } from '@/utils/map/ArcgisUtil'
 
 import {GetPjylLinePaths, GetWaterFlightPoints, GetShipRout} from "@/apis/ssky";
+import {setCenter} from "@/utils/map/Common";
 
 // 浦江游览航线
 export function pjylLine(isShow){
@@ -28,13 +29,13 @@ export function pjylLine(isShow){
                 points.push(first)
 
                 let params = {
-                    // title: res.data[i].get('lineName'),
+                    title: lineData.lineName,
                     type: 'polygon',
                     data: points,
                     edit: false,
                     temp: false,
                     clear: false,
-                    goto: true,
+                    goto: false,
                     attributes: null,
                     symbol: {
                         type: "simple-fill",
@@ -52,13 +53,7 @@ export function pjylLine(isShow){
         })
     }else{
         clearMap({is_draw: false, is_search:true, layers: []})
-        setCamera({
-            x:2667,
-            y:463,
-            z:4000,
-            heading:100,
-            tilt:0
-        })
+        setCenter();
     }
 
 }
@@ -96,13 +91,7 @@ export function onePjylPortLocation(data,isShow){
         })
     }else{
         clearMap({is_draw: false, is_search:true, layers: []})
-        setCamera({
-            x:2667,
-            y:463,
-            z:4000,
-            heading:100,
-            tilt:0
-        })
+        setCenter();
     }
 
 }
@@ -153,13 +142,7 @@ export function oneDjldPortLocation(data,isShow){
         })*/
     }else{
         clearMap({is_draw: false, is_search:true, layers: []})
-        setCamera({
-            x:2667,
-            y:463,
-            z:4000,
-            heading:100,
-            tilt:0
-        })
+        setCenter();
     }
 }
 
@@ -258,13 +241,7 @@ export function djldLine(lineName,isShow){
         })
     }else{
         clearMap({is_draw: false, is_search:true, layers: []})
-        setCamera({
-            x:2667,
-            y:463,
-            z:4000,
-            heading:100,
-            tilt:0
-        })
+        setCenter();
     }
 
 }

+ 3 - 14
src/views/map/Index.vue

@@ -29,6 +29,7 @@
     import {initBridge,fullExtent,calculation,clearMap,setCamera,addLayer} from "@/utils/map/ArcgisUtil"
     import {pjylLine, djldLine,djldLineAll,onePjylPortLocation,oneDjldPortLocation} from '@/utils/map/WaterPassenger'
     import {setBoat, setBoatPath, onLocationBoat, locationBoat} from '@/utils/map/Boat'
+    import {setCenter} from '@/utils/map/Common'
 
     export default {
         name: "MapHome",
@@ -55,13 +56,7 @@
         mounted(){
             //加载地图控件
             initBridge();
-            setCamera({
-                x:2667,
-                y:463,
-                z:4000,
-                heading:100,
-                tilt:0
-            })
+            setCenter();
         },
         methods:{
             fullExtent(){fullExtent()},
@@ -109,13 +104,7 @@
                         locationBoat('413810782')
                         break
                     case '初始视角':
-                        setCamera({
-                            x:2267,
-                            y:483,
-                            z:4000,
-                            heading:100,
-                            tilt:0
-                        })
+                        setCenter();
                         break
                     case '码头泊位':
                         this.isShowPortLayer = !this.isShowPortLayer