| | |
| | | |
| | | |
| | | //openlayer 创建点位 |
| | | window.pointArr = []; |
| | | export function createPointMarker(position, obj) { |
| | | let startFeature = new ol.Feature({ |
| | | geometry: new ol.geom.Point(position), |
| | |
| | | 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: '标记点', |
| | |
| | | }), |
| | | zIndex: 1099, |
| | | }) |
| | | window.pointArr.push(MarkerLayer) |
| | | return MarkerLayer; |
| | | } |
| | | |
| | | //openlayer 地图点击事件 |
| | | export function setClick(state) { |
| | | console.log('setClick'); |
| | | let ponitPanel = document.getElementById('ponitPanel'); |
| | | let overlay = new ol.Overlay({ |
| | | element: ponitPanel, |
| | | autoPan: { |
| | | animation: { |
| | | duration: 250, |
| | | }, |
| | | }, |
| | | }); |
| | | window.map.addOverlay(overlay); |
| | | function handleClick(e) { |
| | | console.log(e.coordinate); |
| | | |
| | | console.log(e,'111') |
| | | |
| | | store.setLayerPanelShow(false); |
| | | |
| | | // 土地管理 |
| | | if (store.tdglInfo.flag) { |
| | | axios |
| | |
| | | ).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 解析器 |
| | |
| | | features: [feature] // 将要素对象加入到图层源中 |
| | | }) |
| | | }); |
| | | window.map.addLayer(window.tdglLine) |
| | | window.mapapi.addLayer(window.tdglLine) |
| | | |
| | | |
| | | axios |
| | |
| | | return; |
| | | } |
| | | |
| | | window.mapapi.forEachFeatureAtPixel(e.pixel, function (feature) { |
| | | |
| | | window.map.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 |
| | | } |
| | | console.log('objdata'); |
| | | store.setPoplayerShowAction(true); |
| | | store.setPoplayerListAction(objdata); |
| | | window.instance = new PoiLayerConstructor({ |
| | | data: { |
| | | list1: objdata |
| | | } |
| | | }); |
| | | window.instance.$mount(); |
| | | |
| | | store.setTdglShow(false); |
| | | store.setTdlgInfo({}); |
| | | store.setdwShow(true); |
| | | store.setdwInfo(objdata); |
| | | // if (window.instance) { |
| | | // window.instance.$destroy(); |
| | | // } |
| | | // window.instance = new PoiLayerConstructor({ |
| | | // data: { |
| | | // list: objdata |
| | | // } |
| | | // }); |
| | | // window.instance.$mount(); |
| | | } |
| | | }); |
| | | } |
| | | if (state) { |
| | | clickEvent = window.map.on('click', handleClick); |
| | | clickEvent = window.mapapi.on('click', handleClick); |
| | | } else { |
| | | ol.Observable.unByKey(clickEvent) |
| | | clickEvent = null |
| | |
| | | |
| | | |
| | | export function flyToPoint(posisitons) { |
| | | window.map.getView().animate({ |
| | | window.mapapi.getView().animate({ |
| | | center: posisitons, |
| | | zoom: 15, |
| | | duration: 1500 |