| | |
| | | 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'; |
| | |
| | | |
| | | //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", |
| | |
| | | |
| | | //openlayer 地图点击事件 |
| | | export function setClick(state) { |
| | | console.log('setClick'); |
| | | let ponitPanel = document.getElementById('ponitPanel'); |
| | | let overlay = new Overlay({ |
| | | let overlay = new ol.Overlay({ |
| | | element: ponitPanel, |
| | | autoPan: { |
| | | animation: { |
| | |
| | | |
| | | // let _clickCallback = callback; |
| | | function handleClick(e) { |
| | | console.log(e.coordinate); |
| | | // 土地管理 |
| | | if (store.tdglInfo.flag) { |
| | | axios |
| | | .get( |
| | | // "http://10.10.4.115:8022/geowinmap_xncs/ds?r=0.9158559377752831&serviceproviderid=map.vectorserviceprovider&serviceid=queryfeature&featcls=225%25E8%258C%2583%25E5%259B%25B4%25E5%2588%2586%25E5%258C%25BA%25E8%25A7%2584%25E5%2588%2592.geojson&lng=" + |
| | | window.gisBaseUrl + "yzxncsApi/geowinmap_xncs/ds?r=0.9158559377752831&serviceproviderid=map.vectorserviceprovider&serviceid=queryfeature&featcls=225%25E8%258C%2583%25E5%259B%25B4%25E5%2588%2586%25E5%258C%25BA%25E8%25A7%2584%25E5%2588%2592.geojson&lng=" + |
| | | e.coordinate[0] + |
| | | "&lat=" + |
| | | e.coordinate[1] + |
| | | "&geom=true&requesttype=json" |
| | | ).then(response => { |
| | | let center = { lon: 0, lat: 0 }; |
| | | if (window.tdglLine) { |
| | | window.map.removeLayer(window.tdglLine); |
| | | window.tdglLine = null; |
| | | } |
| | | var format = new ol.format.WKT(); // 创建一个 WKT 解析器 |
| | | var feature = format.readFeature(response.data.geometry); // 解析 WKT 并生成要素对象 |
| | | |
| | | // 创建一个要素图层 |
| | | window.tdglLine = new ol.layer.Vector({ |
| | | source: new ol.source.Vector({ |
| | | features: [feature] // 将要素对象加入到图层源中 |
| | | }) |
| | | }); |
| | | window.map.addLayer(window.tdglLine) |
| | | |
| | | |
| | | axios |
| | | .get( |
| | | // "http://10.10.4.115:8022//poisearch/guihuacon/getInfo?ydbm=" + |
| | | window.gisBaseUrl + "yzxncsApi/poisearch/guihuacon/getInfo?ydbm=" + |
| | | response.data.NO |
| | | ) |
| | | .then( |
| | | info => { |
| | | let data = info.data.data; |
| | | if (data.yongdishuju === null) { |
| | | objdata = { |
| | | POITYPE: "NOTDGL", |
| | | zwxx: "暂无信息", |
| | | lon: window.clickPOI.lon, |
| | | lat: window.clickPOI.lat, |
| | | } |
| | | } else { |
| | | qiyexinxi = info.data.data.qiyexinxi; |
| | | qysl = data.qiyexinxi.length; |
| | | if (qysl > 0) { |
| | | ydbm = data.qiyexinxi[0]["地块编号"]; |
| | | } else { |
| | | ydbm = data.churangxinxi["ydbh"]; |
| | | } |
| | | try { |
| | | ydlx = data.yongdishuju["ydlxmc"]; |
| | | } catch (e) { } |
| | | try { |
| | | cyfx = data.yongdishuju["cyfx"]; |
| | | } catch (e) { } |
| | | try { |
| | | // this.crzt = response.data["ZT"]; |
| | | switch (response.data["ZT"]) { |
| | | case 3: |
| | | crzt = "已出让"; |
| | | break; |
| | | case 4: |
| | | crzt = "未出让"; |
| | | break; |
| | | } |
| | | } catch (e) { } |
| | | try { |
| | | ydmj = parseFloat( |
| | | "" + data.yongdishuju["ydmj"] |
| | | ).toFixed(0); |
| | | } catch (e) { } |
| | | try { |
| | | crnx = data.churangxinxi["crnx"]; |
| | | } catch (e) { } |
| | | try { |
| | | crnf = data.churangxinxi["crnf"]; |
| | | } catch (e) { } |
| | | try { |
| | | rjl = data.yongdishuju["rjl"]; |
| | | } catch (e) { } |
| | | try { |
| | | jzxg = data.yongdishuju["jzxg"]; |
| | | } catch (e) { } |
| | | try { |
| | | jzmd = data.yongdishuju["jzmd"]; |
| | | } catch (e) { } |
| | | objdata = { |
| | | POITYPE: "TDGL", |
| | | ydbm, |
| | | ydlx, |
| | | cyfx, |
| | | crzt, |
| | | ydmj, |
| | | ydbm, |
| | | crnx, |
| | | crnf, |
| | | rjl, |
| | | jzxg, |
| | | jzmd, |
| | | lon:e.coordinate[0], |
| | | lat: e.coordinate[1], |
| | | } |
| | | } |
| | | |
| | | store.setTdglShow(false); |
| | | store.setTdlgInfo({}); |
| | | store.setTdglShow(true); |
| | | store.setTdlgInfo(objdata); |
| | | } |
| | | ); |
| | | |
| | | }) |
| | | return; |
| | | } |
| | | |
| | | |
| | | 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", |
| | |
| | | <span>地址:</span> |
| | | <span>${objdata.address}</span> |
| | | </div>` |
| | | overlay.setPosition(e.coordinate); |
| | | |
| | | setTimeout(() => { |
| | | overlay.setPosition(e.coordinate); |
| | | }, 0) |
| | | |
| | | // store.setPoplayerShowAction(true); |
| | | // store.setPoplayerListAction(objdata); |
| | |
| | | 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, |
| | | // } |
| | | // ); |
| | | } |