From f027164f4ee3f8a234f1a5dfd61eb3cceaa13fb7 Mon Sep 17 00:00:00 2001
From: ZhAkps <46207005+ZhAkps@users.noreply.github.com>
Date: 星期二, 06 二月 2024 16:15:11 +0800
Subject: [PATCH] Merge branch 'master' of http://106.120.22.35:48888/r/PM20221203225_MobileWeb

---
 src/utils/map2.js |   73 ++++++++++++++++++++----------------
 1 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/src/utils/map2.js b/src/utils/map2.js
index 977fba4..19e3c86 100644
--- a/src/utils/map2.js
+++ b/src/utils/map2.js
@@ -1,10 +1,10 @@
-import { Feature } from "ol";
-import VectorLayer from "ol/layer/Vector";
-import VectorSource from "ol/source/Vector";
-import { Style, Icon, Fill, Stroke, Text, Circle as CircleStyle } from "ol/style";
-import { Point, LineString } from "ol/geom";
-import Overlay from 'ol/Overlay.js';
-import { unByKey } from "ol/Observable.js"; //绉婚櫎浜嬩欢
+// import { Feature } from "ol";
+// import VectorLayer from "ol/layer/Vector";
+// import VectorSource from "ol/source/Vector";
+// import { Style, Icon, Fill, Stroke, Text, Circle as CircleStyle } from "ol/style";
+// import { Point, LineString } from "ol/geom";
+// import Overlay from 'ol/Overlay.js';
+// import { unByKey } from "ol/Observable.js"; //绉婚櫎浜嬩欢
 import Vue from 'vue';
 import axios from "axios";
 import _GLOBAL from '@/assets/GLOBAL2';
@@ -2204,20 +2204,20 @@
 
 //openlayer 鍒涘缓鐐逛綅
 export function createPointMarker(position, obj) {
-    let startFeature = new Feature({
-        geometry: new Point(position),
+    let startFeature = new ol.Feature({
+        geometry: new ol.geom.Point(position),
     });
     startFeature.setProperties({
         desc: obj,
     });
-    let MarkerLayer = new VectorLayer({
+    let MarkerLayer = new ol.layer.Vector({
         id: 'LocationPoint',
         name: '鏍囪鐐�',
-        source: new VectorSource({
+        source: new ol.source.Vector({
             features: [startFeature],
         }),
-        style: new Style({
-            image: new Icon({
+        style: new ol.style.Style({
+            image: new ol.style.Icon({
                 src: require('@/assets/img/collection/scdw.png'),
                 anchorOrigin: "top-left",
                 anchorXUnits: "fraction",
@@ -2235,7 +2235,7 @@
 //openlayer 鍦板浘鐐瑰嚮浜嬩欢
 export function setClick(state) {
     let ponitPanel = document.getElementById('ponitPanel');
-    let overlay = new Overlay({
+    let overlay = new ol.Overlay({
         element: ponitPanel,
         autoPan: {
             animation: {
@@ -2250,6 +2250,8 @@
         window.map.forEachFeatureAtPixel(e.pixel, function (feature) {
             // console.log(feature, '111111')
             if (feature && feature.values_.desc) {
+                ponitPanel.style.display = 'block'
+
                 let obj = feature.values_.desc
                 objdata = {
                     POITYPE: "POINT",
@@ -2269,7 +2271,10 @@
                         <span>鍦板潃锛�</span>
                        <span>${objdata.address}</span>
                     </div>`
-                overlay.setPosition(e.coordinate);
+
+                setTimeout(() => {
+                    overlay.setPosition(e.coordinate);
+                }, 0)
 
                 // store.setPoplayerShowAction(true);
                 // store.setPoplayerListAction(objdata);
@@ -2288,31 +2293,33 @@
     if (state) {
         clickEvent = window.map.on('click', handleClick);
     } else {
-        unByKey(clickEvent)
+        ol.Observable.unByKey(clickEvent)
         clickEvent = null
     }
 }
 
 
 export function flyToPoint(posisitons) {
-    let zoom = window.map.getView().getZoom();
-    if (zoom >= 16) {
-        zoom = 12
-    }
-    let duration = 2000;
+    // let zoom = window.map.getView().getZoom();
+    // if (zoom >= 16) {
+    //     zoom = 12
+    // }
+    // let duration = 2000;
     window.map.getView().animate({
         center: posisitons,
+        zoom: 12,
+        duration: 1500
     })
-    window.map.getView().animate(
-        //鍔ㄧ敾寮�濮嬫椂
-        {
-            zoom: zoom > 16 ? zoom - 0.01 : zoom + 0.01,
-            duration: duration / 2,
-        },
-        //鍔ㄧ敾缁撴潫鏃�
-        {
-            zoom: zoom >= 16 ? 16 : zoom + 4,
-            duration: duration / 2,
-        }
-    );
+    // window.map.getView().animate(
+    //     //鍔ㄧ敾寮�濮嬫椂
+    //     {
+    //         zoom: zoom > 16 ? zoom - 0.01 : zoom + 0.01,
+    //         duration: duration / 2,
+    //     },
+    //     //鍔ㄧ敾缁撴潫鏃�
+    //     {
+    //         zoom: zoom >= 16 ? 16 : zoom + 4,
+    //         duration: duration / 2,
+    //     }
+    // );
 }
\ No newline at end of file

--
Gitblit v1.9.3