import config from "@/api/config.js"; import * as KMap from "@/utils/ol-map/KMap"; import * as util from "@/common/ol_common.js"; import Point from "ol/geom/Point.js"; import Feature from "ol/Feature"; import VectorLayer from "ol/layer/Vector.js"; import WKT from "ol/format/WKT.js"; import ScaleLine from "ol/control/ScaleLine"; import { useRouter } from "vue-router"; import Overlay from 'ol/Overlay' import eventBus from "@/api/eventBus"; /** * @description 地图层对象 */ class HomeMap { constructor() { let that = this; let vectorStyle = new KMap.VectorStyle(); this.vectorStyle = vectorStyle; } initMap(location, target) { let level = 6; let coordinate = util.wktCastGeom(location).getFirstCoordinate(); this.kmap = new KMap.Map(target, level, coordinate[0], coordinate[1], null, 6, 22); eventBus.emit('warningMap:init', this.kmap); this.addPopup() this.addMapListen() } addMapListen() { let that = this // 监听地图点击事件 // 创建弹窗图层 this.popup = new Overlay({ element: document.getElementById('popup'), positioning: 'bottom-center', offset: [0, -10], }); this.kmap.map.addOverlay(this.popup); setTimeout(() => { console.log(''); // this.popup.getElement().innerHTML = `
Feature properties: