北京经济技术开发区经开区虚拟城市项目-【前端】-移动端Web
111
少年
2024-02-07 f7ab8838f095134c65d2628fe54a6fb8c5df146e
src/utils/map2.js
@@ -8,7 +8,7 @@
import Vue from 'vue';
import axios from "axios";
import _GLOBAL from '@/assets/GLOBAL2';
import poiLayer2 from '@/components/poplayer/main2';
import poiLayer from '@/components/poplayer/main';
import store from "@/utils/store2";
import { Message } from 'element-ui';
let tdglLine, qiyexinxi, qysl, ydbm, ydlx, cyfx, crzt, ydmj, crnx, crnf, rjl, jzxg, jzmd;
@@ -16,7 +16,7 @@
var clickEvent;
window.tdglLine = tdglLine
let PoiLayerConstructor = Vue.extend(poiLayer2);
let PoiLayerConstructor = Vue.extend(poiLayer);
/**核心区 */
export function loadHXQ() {
    let urls = window.gisBaseUrl + "/gisserver/wmsserver/YZ_BJ60";
@@ -2203,6 +2203,7 @@
//openlayer 创建点位
window.pointArr = [];
export function createPointMarker(position, obj) {
    let startFeature = new ol.Feature({
        geometry: new ol.geom.Point(position),
@@ -2210,6 +2211,12 @@
    startFeature.setProperties({
        desc: obj,
    });
    if (window.pointArr && window.pointArr.length > 0) {
        window.pointArr.forEach(item => {
            window.mapapi.removeLayer(item)
        })
        window.pointArr = []
    }
    let MarkerLayer = new ol.layer.Vector({
        id: 'LocationPoint',
        name: '标记点',
@@ -2229,13 +2236,18 @@
        }),
        zIndex: 1099,
    })
    window.pointArr.push(MarkerLayer)
    return MarkerLayer;
}
//openlayer 地图点击事件
export function setClick(state) {
    function handleClick(e) {
        console.log(e.coordinate);
        console.log(e,'111')
        store.setLayerPanelShow(false);
        // 土地管理
        if (store.tdglInfo.flag) {
            axios
@@ -2249,7 +2261,7 @@
                ).then(response => {
                    let center = { lon: 0, lat: 0 };
                    if (window.tdglLine) {
                        window.map.removeLayer(window.tdglLine);
                        window.mapapi.removeLayer(window.tdglLine);
                        window.tdglLine = null;
                    }
                    var format = new ol.format.WKT(); // 创建一个 WKT 解析器
@@ -2261,7 +2273,7 @@
                            features: [feature] // 将要素对象加入到图层源中
                        })
                    });
                    window.map.addLayer(window.tdglLine)
                    window.mapapi.addLayer(window.tdglLine)
                    axios
@@ -2354,15 +2366,17 @@
            return;
        }
        window.map.forEachFeatureAtPixel(e.pixel, function (feature) {
        window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) {
            console.log(feature,'feature')
            if (feature && feature.values_.desc) {
                let obj = feature.values_.desc
                objdata = {
                    POITYPE: "POINT",
                    name: obj.name,
                    address: obj.address,
                    lon: obj.lng,
                    lat: obj.lat
                    // lon: obj.lng,
                    // lat: obj.lat
                }
                store.setTdglShow(false);
@@ -2382,7 +2396,7 @@
        });
    }
    if (state) {
        clickEvent = window.map.on('click', handleClick);
        clickEvent = window.mapapi.on('click', handleClick);
    } else {
        ol.Observable.unByKey(clickEvent)
        clickEvent = null
@@ -2391,7 +2405,7 @@
export function flyToPoint(posisitons) {
    window.map.getView().animate({
    window.mapapi.getView().animate({
        center: posisitons,
        zoom: 15,
        duration: 1500