lrf hace 1 año
padre
commit
8e9ccd5c47
Se han modificado 6 ficheros con 19 adiciones y 14 borrados
  1. 2 0
      .gitignore
  2. 3 2
      public/index.html
  3. 5 5
      src/plugins/amap.js
  4. 3 0
      src/router/index.js
  5. 5 6
      src/views/fence/track/index.vue
  6. 1 1
      vue.config.js

+ 2 - 0
.gitignore

@@ -2,6 +2,8 @@
 node_modules
 package-lock.json
 /dist
+sps.zip
+sps/
 
 
 # local env files

+ 3 - 2
public/index.html

@@ -44,10 +44,11 @@
       securityJsCode: 'ac773516846f5fff7ca6a1a10ae695cb',
     }
   </script>
+  <script src="https://webapi.amap.com/loader.js"></script>
   <!-- <script
     src="https://webapi.amap.com/maps?v=2.0&key=aad60badbcbc4d90b68337ee0ef27204&plugin=AMap.Scale,AMap.ToolBar,AMap.MouseTool"></script> -->
-    <script type="text/javascript"
-    src="https://webapi.amap.com/loca?v=2.0.0&key=aad60badbcbc4d90b68337ee0ef27204"></script>
+    <!-- <script type="text/javascript"
+    src="https://webapi.amap.com/loca?v=2.0.0&key=aad60badbcbc4d90b68337ee0ef27204"></script> -->
   <noscript>
     <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
         Please enable it to continue.</strong>

+ 5 - 5
src/plugins/amap.js

@@ -11,11 +11,11 @@ export default function MapLoader() {
         'http://webapi.amap.com/maps?v=2.0&callback=initAMap&key=aad60badbcbc4d90b68337ee0ef27204&plugin=AMap.Scale,AMap.ToolBar,AMap.MouseTool,AMap.PolyEditor,AMap.RectangleEditor,AMap.AutoComplete,AMap.PlaceSearch';
       script.onerror = reject;
       document.head.appendChild(script);
-      // let localScript = document.createElement('script');
-      // localScript.type = 'text/javascript';
-      // localScript.src = 'https://webapi.amap.com/loca?v=2.0.0&key=aad60badbcbc4d90b68337ee0ef27204';
-      // localScript.onerror = reject;
-      // document.head.appendChild(localScript);
+      let localScript = document.createElement('script');
+      localScript.type = 'text/javascript';
+      localScript.src = 'https://webapi.amap.com/loca?v=2.0.0&key=aad60badbcbc4d90b68337ee0ef27204';
+      localScript.onerror = reject;
+      document.head.appendChild(localScript);
     }
     window.initAMap = () => {
       resolve(window.AMap);

+ 3 - 0
src/router/index.js

@@ -278,7 +278,10 @@ const router = new VueRouter({
   routes,
 });
 const whiteList = ['/census', '/watch/ward', '/watch/warning'];
+import MapLoader from '@/plugins/amap';
 router.beforeEach((to, from, next) => {
+  // 初始化地图
+  if (!_.get(window, 'AMap')) MapLoader();
   document.title = `${to.meta.title} `;
   const token = sessionStorage.getItem('token');
   if (to.path === '/login') {

+ 5 - 6
src/views/fence/track/index.vue

@@ -90,11 +90,11 @@ export default {
         center: this.center,
         // mapStyle: this.mapStyle,
       });
-      let loca = this.initLoca(map);
-      loca.animate.start();
-      this.loca = loca;
       map.on('complete', () => {
         this.map = map;
+        let loca = this.initLoca(map);
+        loca.animate.start();
+        this.loca = loca;
       });
     },
     // 更换数据:先把数据查好,处理完,放到points中;再调用这个
@@ -155,7 +155,6 @@ export default {
       // 组织数据
       let mapData = this.initMapLine(this.points);
       let mapGeo = this.initGeoData(mapData);
-      console.log(mapGeo);
       // 生成脉冲图 图层
       let layer = new Loca.PulseLineLayer({
         zIndex: 10,
@@ -174,9 +173,9 @@ export default {
         // 脉冲尾颜色
         trailColor: 'rgba(128, 128, 128, 0.5)',
         // 脉冲长度,0.25 表示一段脉冲占整条路的 1/4
-        interval: 0.25,
+        interval: 0.20,
         // 脉冲线的速度,几秒钟跑完整段路
-        duration: 20000,
+        duration: 15000,
       });
       this.loca.add(layer);
       this.pulse = layer;

+ 1 - 1
vue.config.js

@@ -23,7 +23,7 @@ module.exports = {
         target: 'http://sps.fwedzgc.com:8090',
       },
       '/psychosis/api': {
-        target: 'http://sps.fwedzgc.com:8090', //http://sps.fwedzgc.com:8090  http://192.168.43.105:6200
+        target: 'http://127.0.0.1:6200', //http://sps.fwedzgc.com:8090  http://192.168.43.105:6200
         changeOrigin: true,
         ws: false,
       },