| | |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | let pointLayer = null |
| | | export default { |
| | | name: "dcSearchMap", |
| | | props: ['isDetail', 'point'], |
| | | data () { |
| | | data() { |
| | | return { |
| | | pointLayer: null, |
| | | currentPoint: null, |
| | | //绘制工具 |
| | | plotTool: null, |
| | | coordinates: [] |
| | | } |
| | | }, |
| | | created () { |
| | | created() { |
| | | |
| | | }, |
| | | mounted () { |
| | | mounted() { |
| | | |
| | | }, |
| | | methods: { |
| | | init () { |
| | | init() { |
| | | let self = this |
| | | if (global.searchViewer != null) { |
| | | global.searchViewer = null |
| | |
| | | initViewer() |
| | | }) |
| | | |
| | | function initViewer () { |
| | | function initViewer() { |
| | | //配置viewer |
| | | global.searchViewer = new global.DC.Viewer('search-viewer-container', { |
| | | contextOptions: { |
| | |
| | | // ) |
| | | |
| | | //添加图层 |
| | | self.pointLayer = new global.DC.VectorLayer('polygonLayer') |
| | | global.searchViewer.addLayer(self.pointLayer) |
| | | pointLayer = new global.DC.VectorLayer('polygonLayer') |
| | | global.searchViewer.addLayer(pointLayer) |
| | | |
| | | self.plotTool = new global.DC.Plot(global.searchViewer, { |
| | | icon_center: "/img/dwicon.jpeg", // 自定义的中心点图标 |
| | |
| | | |
| | | }, |
| | | //开始绘画 |
| | | draw () { |
| | | draw() { |
| | | const self = this |
| | | if (this.polygon) { |
| | | this.clearDraw() |
| | |
| | | //鼠标左键事件 |
| | | let leftClick = function (event) { |
| | | if (self.currentPoint) { |
| | | self.pointLayer.removeOverlay(self.currentPoint) |
| | | pointLayer.removeOverlay(self.currentPoint) |
| | | self.currentPoint = null |
| | | } |
| | | let point = new global.DC.Billboard(new global.DC.Position(event.wgs84SurfacePosition.lng, event.wgs84SurfacePosition.lat), 'img/dwicon.jpeg') |
| | |
| | | // outlineWidth: 2, //边框大小, |
| | | // }) |
| | | self.currentPoint = point |
| | | self.pointLayer.addOverlay(point) |
| | | pointLayer.addOverlay(point) |
| | | let pointLonLat = [event.wgs84SurfacePosition.lng, event.wgs84SurfacePosition.lat] |
| | | self.$emit("getMapData", pointLonLat) |
| | | } |
| | |
| | | global.searchViewer.on(global.DC.MouseEventType.LEFT_DOWN, leftClick) |
| | | }, |
| | | //重置 |
| | | clearDraw () { |
| | | clearDraw() { |
| | | this.polygonLayer.clear() |
| | | }, |
| | | //转换成数据库数据 |
| | | doData (val) { |
| | | doData(val) { |
| | | let str = "LINESTRING(" |
| | | for (let k = 0; k < val.length; k++) { |
| | | str += `${val[k][0]} ${val[k][1]}` |
| | |
| | | return '\'' + str + '\'' |
| | | }, |
| | | //回显点 |
| | | showPoint (positions) { |
| | | showPoint(positions) { |
| | | let viewer = global.searchViewer |
| | | if (positions) { |
| | | let pointData = "" |
| | |
| | | // outlineWidth: 2, //边框大小, |
| | | // }) |
| | | this.currentPoint = point |
| | | this.pointLayer.addOverlay(point) |
| | | viewer.flyTo(this.pointLayer) |
| | | pointLayer.addOverlay(point) |
| | | viewer.flyTo(pointLayer) |
| | | } |
| | | }, |
| | | setView(points) { |
| | | if (points) { |
| | | let position = new global.DC.Position(Number(points.lng), Number(points.lat), 2000, 0, -90, 0) |
| | | let point = new global.DC.Billboard(position, 'img/dwicon.jpeg') |
| | | this.currentPoint = point |
| | | pointLayer.clear() |
| | | pointLayer.addOverlay(point) |
| | | global.searchViewer.flyToPosition( |
| | | new global.DC.Position(Number(points.lng), Number(points.lat), 2000, 0, -90, 0) |
| | | ) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | </style> |
| | | <style scoped></style> |
| | |
| | | let ak = this.ak |
| | | let region = this.region |
| | | let query = this.queryString |
| | | let ids = "61743e28bbf11700e9fc4ef03dd8bea9" |
| | | searchByQuery(ak, region, query, ids).then(res => { |
| | | searchByQuery(ak, region, query).then(res => { |
| | | let dataList = res.data.result |
| | | this.searchList = dataList |
| | | }) |
| | |
| | | let page_size = "1" |
| | | let page_num = "1" |
| | | let infos = 1 |
| | | let radius = 500 |
| | | let radius = 100 |
| | | let location = this.longitude + " " + this.latitude |
| | | searchByLonLat(ak, query, region, region_type, page_size, page_num, infos, radius, location).then(res => { |
| | | let data = res.data.result[0] |
| | |
| | | }, |
| | | selectChange(data) { |
| | | let selectData = JSON.parse(data) |
| | | this.$refs.OpenLayersMap.setView(selectData.location) |
| | | |
| | | this.$emit("getLonLat", [selectData.location.lng, selectData.location.lat]) |
| | | this.$emit("getAddress", selectData.address) |
| | | |
| | | this.$refs.dcSearchMap.setView(selectData.location) |
| | | } |
| | | } |
| | | } |