Parcourir la source

添加全厂厂房信息提示

liling il y a 2 semaines
Parent
commit
111a5eb02f
2 fichiers modifiés avec 124 ajouts et 1 suppressions
  1. 121 1
      src/pages/components/Fac.vue
  2. 3 0
      src/pages/main/index.vue

+ 121 - 1
src/pages/components/Fac.vue

@@ -226,6 +226,10 @@ export default {
                 try{
                     backMasterViewByFac();
                     if(player!=null && player.Native!=null){
+                        player.on('mousemove',function(x,y){
+                            console.log('mousemove:',x,y)
+                            isMoveInBuild(x,y);
+                        });
                         (async()=>{
                             let marklst = await player.Native.GisMarker.getMarkerList();
                             if(marklst!=null){
@@ -234,6 +238,10 @@ export default {
                                 }
                             }
                             loadmarkers();
+                            setTimeout(() => {
+                                //需要延迟加载,等待今日库存统计板板先显示
+                                loadBuilderInfo();
+                            }, 1000);                            
                         })();
                     }
                     MarkerMapFac["FAC"] = {};
@@ -312,6 +320,78 @@ export default {
             [-0.2149817792494004, 0.7110548607426664, 0.6694653236762824], 1);
         }
 
+        function isPointInPolygon(lat, lon, polygon) {
+            let intersectCount = 0;
+            const pointCount = polygon.length;
+
+            for (let i = 0; i < pointCount; i++) {
+                const vertex1 = polygon[i];
+                const vertex2 = polygon[(i + 1) % pointCount];
+                if (
+                (lat > Math.min(vertex1.latitude, vertex2.latitude) &&
+                lat <= Math.max(vertex1.latitude, vertex2.latitude)) &&
+                (lon <= Math.max(vertex1.longitude, vertex2.longitude))
+                ) {
+                    const xIntersect =
+                    ((lat - vertex1.latitude) * (vertex2.longitude - vertex1.longitude)) /
+                    (vertex2.latitude - vertex1.latitude) +
+                    vertex1.longitude;
+
+                    if (lon < xIntersect) {
+                        intersectCount++;
+                    }
+                }
+            }
+
+            return intersectCount % 2 !== 0;
+        }
+
+        function isMoveInBuild(x,y){ 
+            let buildingNo = isMoveIn01thBuild(x,y);
+            if(buildingNo=="") buildingNo = isMoveIn02thBuild(x,y);
+            if(buildingNo=="")  buildingNo = isMoveIn03thBuild(x,y);
+            if(buildingNo=="")  buildingNo = isMoveIn04thBuild(x,y);
+                for (var marker in MarkerMapFac["FAC"]) {
+                    var opt = MarkerMapFac["FAC"][marker];
+                    var dataType = opt["building"];
+                    if(dataType==null || dataType=="") continue;
+                    if(dataType==buildingNo){
+                        if(!opt.visible){
+                            opt.visible = true;
+                            player.Native.GisMarker.update(marker, opt);
+                        }
+                    }else if(opt.visible){
+                        opt.visible = false;
+                        player.Native.GisMarker.update(marker, opt);
+                    }
+                }
+            }
+
+        function isMoveIn01thBuild(x,y){
+            if(isPointInPolygon(x,y,BuilderXY["01"])){
+                return "01";
+            }
+            return "";
+        }
+        function isMoveIn02thBuild(x,y){
+            if(isPointInPolygon(x,y,BuilderXY["02"])){
+                return "02";
+            }
+            return "";
+        }
+        function isMoveIn03thBuild(x,y){
+            if(isPointInPolygon(x,y,BuilderXY["03"])){
+                return "03";
+            }
+            return "";
+        }
+        function isMoveIn04thBuild(x,y){
+            if(isPointInPolygon(x,y,BuilderXY["04"])){
+                return "04";
+            }
+            return "";
+        }
+
         async function updateMarkerData(){
             if(MarkerMapFac==null) return;
             for (var key in MarkerMapFac) {
@@ -346,6 +426,46 @@ export default {
                         }
                     }
         }
+
+        async function loadBuilderInfo(){ 
+            var imgid = await player.Native.GisMarker.loadImage("data://icon/qietu/tip_red.png");
+            var options = {
+                "text": "1号厂房\r\r长133米*宽78米*高40米",
+                "visible": false,
+                //"maxLod": 130,
+                "minLod": 0,
+                "textFontSize":16,
+                "textColor": parseInt("0xedededff"),
+                "contentPadding":[10,10,10,10],
+                "nodeOffset":[-104,-85],
+                "building": ""
+            };
+            options.pos = [-47.242690563201904, -107.442626953125, 46.22212219238281];
+            options.imgId = imgid
+            options.imgSize = [200, 100];
+            options.building = "01";
+            var markPtr = await player.Native.GisMarker.create(options);
+            if(MarkerMapFac["FAC"]==null) MarkerMapFac["FAC"]={};
+            MarkerMapFac["FAC"][markPtr]=options;
+            let option4= JSON.parse(JSON.stringify(options));
+            option4.text = "4号厂房\r\r长37米*宽62米*高33米";
+            option4.pos = [-215.53692626953125, -9.105635643005371, 38.3607177734375];
+            option4.building = "04";
+            var markPtr = await player.Native.GisMarker.create(option4);
+            MarkerMapFac["FAC"][markPtr]=option4;
+            let option2= JSON.parse(JSON.stringify(options));
+            option2.text = "2号厂房\r\r长306米*宽62米*高45米";
+            option2.pos = [78.97850799560547, -7.938839912414551, 31.4000244140625];
+            option2.building = "02";
+            var markPtr = await player.Native.GisMarker.create(option2);
+            MarkerMapFac["FAC"][markPtr]=option2;
+            let option3= JSON.parse(JSON.stringify(options));
+            option3.text = "3号厂房\r\r长286米*宽62.8米*高23.4米";
+            option3.pos = [-60.97850799560547, 77.938839912414551, 31.4000244140625];
+            option3.building = "03";
+            var markPtr = await player.Native.GisMarker.create(option3);
+            MarkerMapFac["FAC"][markPtr]=option3;
+        }
         async function loadmarkers(){
                 //获取4号楼顶对象
                 //var obj02 = await player.Native.ModelTree.findItemByName("Box013",0,true,1);
@@ -370,7 +490,7 @@ export default {
                 options.imgSize = [0, 140];
                 var markPtr = await player.Native.GisMarker.create(options);
                 //await player.Native.GisMarker.update(markPtr, options);
-                MarkerMapFac["FAC"]={};
+                if(MarkerMapFac["FAC"]==null) MarkerMapFac["FAC"]={};
                 MarkerMapFac["FAC"][markPtr]=options;
                 //获取盘头仓对象
                 //var pantou = await player.Native.ModelTree.findItemByName("Object023",0,true,1);

+ 3 - 0
src/pages/main/index.vue

@@ -350,6 +350,9 @@ export default {
                     //updateInfo("RClick", event)
                 });
             })
+            player.on("mosuewheel",function(x,y,wheelDeltaY){
+                console.log('MouseWheel:',x,y,wheelDeltaY)
+            })
         }
         function getBottomBtnImg(imgname, type){
             if(currentTargetType.value==type) return require('@/assets/image/'+imgname+'_active.png');