Bläddra i källkod

优化ol地图组件

jiuling 8 månader sedan
förälder
incheckning
1ee819f67c
1 ändrade filer med 20 tillägg och 11 borttagningar
  1. 20 11
      src/components/OlMap/index.vue

+ 20 - 11
src/components/OlMap/index.vue

@@ -597,15 +597,23 @@ export default {
       );
 
       // 创建一个图层,专门用于展示瓦片地图,这里的关键是要设置好url,这个url就是LD导航系统提供的获取瓦片对应的接口
-      this.map.addLayer(
-            new TileLayer({
-                source: new SrcXYZ({
-                    url: this.url+ '/v1/tilemap/tile/'+this.mapName+'/{z}/{x}/{y}.png',
-                    wrapX: true,
-                    projection: new Projection({extent: tile_param.projection.extent})
-                })
-            })
-        );
+      this.baseLayer = new TileLayer({
+        source: new SrcXYZ({
+          url: this.url+ '/v1/tilemap/tile/'+this.mapName+'/{z}/{x}/{y}.png',
+          wrapX: true,
+          projection: new Projection({extent: tile_param.projection.extent})
+        }),
+      });
+      this.map.addLayer(this.baseLayer);
+      // this.map.addLayer(
+      //       new TileLayer({
+      //           source: new SrcXYZ({
+      //               url: this.url+ '/v1/tilemap/tile/'+this.mapName+'/{z}/{x}/{y}.png',
+      //               wrapX: true,
+      //               projection: new Projection({extent: tile_param.projection.extent})
+      //           })
+      //       })
+      //   );
 /*       this.baseLayer = new TileLayer({
         source: new SrcXYZ({
           tileUrlFunction: ($xyz) => {
@@ -748,7 +756,6 @@ export default {
 
     // robot 位置信息映射
     initRobot() {
-      console.log("robot 位置信息映射");
       
       var robot_feature = new Feature({
         geometry: new Point([this.robotPoseData.x, this.robotPoseData.y]),
@@ -758,7 +765,8 @@ export default {
           image: new Icon({
             src: require("@/assets/icons/olmap/robot.png"),
             rotateWithView: true,
-            rotation: Math.PI - this.robotPoseData.angle
+            rotation: 0   // 设置一个比轨迹线大的值
+            // rotation: Math.PI - this.robotPoseData.angle
           }),
         })
       );
@@ -774,6 +782,7 @@ export default {
       this.map.addLayer(
         new VectorLayer({
           source: this.robot_src,
+          zIndex: 10 
         })
       );
     },