| | |
| | | </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> |