|
|
@@ -42,7 +42,7 @@
|
|
|
<div v-if="type==3" class="deleteForm">
|
|
|
<div class="title">作业点基本信息</div>
|
|
|
<div class="item">
|
|
|
- <div class="lable">作业项:</div>
|
|
|
+ <div class="lable">作业项目:</div>
|
|
|
<div class="content">
|
|
|
<img class="icon" :src="deleteForm.icon" alt="">
|
|
|
<span>{{ deleteForm.name }}</span>
|
|
|
@@ -185,7 +185,7 @@ export default {
|
|
|
this.dragstartMarker = undefined
|
|
|
return
|
|
|
}
|
|
|
- if (this.map._layers[this.layer._leaflet_id]) {
|
|
|
+ if (this.layer._leaflet_id && this.map._layers[this.layer._leaflet_id]) {
|
|
|
this.map.removeLayer(this.map._layers[this.layer._leaflet_id])
|
|
|
}
|
|
|
},
|
|
|
@@ -231,65 +231,67 @@ export default {
|
|
|
this.getLayers()
|
|
|
},
|
|
|
getLayers() {
|
|
|
- const self = this
|
|
|
getLayersApi().then((res) => {
|
|
|
- const markers = L.layerGroup()
|
|
|
- const coordinates = [-100, 100]
|
|
|
- const options = { id: 1 }
|
|
|
- const icon = 'project-12'
|
|
|
- const tip = '盲板抽堵作业'
|
|
|
- const iconSize = [27, 33]
|
|
|
- function drawMark(option = { tip, icon, options, coordinates }) {
|
|
|
- const myIcon = L.divIcon({
|
|
|
- // iconUrl: require(`./images/layers/${option.options.typeId}.png`),
|
|
|
- className: option.icon,
|
|
|
- iconSize: iconSize
|
|
|
- })
|
|
|
- const marker = L.marker(option.coordinates, { ...option.options, icon: myIcon, draggable: false })
|
|
|
+ this.initMarkers(res.data)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ initMarkers(markerList = []) {
|
|
|
+ const self = this
|
|
|
+ const markers = L.layerGroup()
|
|
|
+ const coordinates = [-100, 100]
|
|
|
+ const options = { id: 1 }
|
|
|
+ const icon = 'project-12'
|
|
|
+ const tip = '盲板抽堵作业'
|
|
|
+ const iconSize = [27, 33]
|
|
|
+ function drawMark(option = { tip, icon, options, coordinates }) {
|
|
|
+ const myIcon = L.icon({
|
|
|
+ iconUrl: require(`./images/layers/${option.options.typeId}.png`),
|
|
|
+ className: option.icon,
|
|
|
+ iconSize: iconSize
|
|
|
+ })
|
|
|
+ const marker = L.marker(option.coordinates, { ...option.options, icon: myIcon, draggable: false })
|
|
|
// .bindPopup(option.tip)
|
|
|
- .addTo(markers)
|
|
|
- marker.on('click', function(ev) {
|
|
|
- if (self.type === 'drage') {
|
|
|
- self.$message.success('请先确认当前标记点操作!')
|
|
|
- return
|
|
|
- }
|
|
|
- const id = ev.target.options?.id
|
|
|
- self.type = 3
|
|
|
- self.veditId = id
|
|
|
- self.markerId = ev.target._leaflet_id
|
|
|
- self.deleteForm.name = ev.target.options.name
|
|
|
- self.deleteForm.icon = require(`./images/layers/${ev.target.options.typeId}.png`)
|
|
|
- marker.dragging.enable()
|
|
|
- })
|
|
|
- marker.on('dragstart', function(ev) {
|
|
|
- const id = ev.target.options?.id
|
|
|
- self.type = 'drage'
|
|
|
- if (self.dragstartMarker === undefined) {
|
|
|
- self.dragstartMarker = { marker, _latlng: ev.target._latlng }
|
|
|
- }
|
|
|
- self.veditId = id
|
|
|
- self.markerId = ev.target._leaflet_id
|
|
|
- self.saveForm.name = ev.target.options.name
|
|
|
- self.saveForm.icon = require(`./images/layers/${ev.target.options.typeId}.png`)
|
|
|
- })
|
|
|
- marker.on('dragend', function(ev) {
|
|
|
- self.layer = ev.target
|
|
|
- })
|
|
|
- }
|
|
|
- markers.addTo(this.map)
|
|
|
- this.markerGroup = markers
|
|
|
- const markerList = res.data
|
|
|
- if (markerList && markerList.length > 0) {
|
|
|
- for (let i = 0; i < markerList.length; i++) {
|
|
|
- drawMark({
|
|
|
- // tip: `${markerList[i].jobactivityTitle}`,
|
|
|
- icon: `project-${markerList[i].typeId}`,
|
|
|
- coordinates: [markerList[i].jobactQywzwd, markerList[i].jobactQywzjd],
|
|
|
- options: { id: markerList[i].veditId, typeId: markerList[i].typeId, name: markerList[i].jobactivityTitle }
|
|
|
- })
|
|
|
+ .addTo(markers)
|
|
|
+ marker.on('click', function(ev) {
|
|
|
+ if (self.type === 'drage') {
|
|
|
+ self.$message.success('请先确认当前标记点操作!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const id = ev.target.options?.id
|
|
|
+ self.type = 3
|
|
|
+ self.veditId = id
|
|
|
+ self.markerId = ev.target._leaflet_id
|
|
|
+ self.deleteForm.name = ev.target.options.name
|
|
|
+ self.deleteForm.icon = require(`./images/layers/${ev.target.options.typeId}.png`)
|
|
|
+ marker.dragging.enable()
|
|
|
+ })
|
|
|
+ marker.on('dragstart', function(ev) {
|
|
|
+ const id = ev.target.options?.id
|
|
|
+ self.type = 'drage'
|
|
|
+ if (self.dragstartMarker === undefined) {
|
|
|
+ self.dragstartMarker = { marker, _latlng: ev.target._latlng }
|
|
|
}
|
|
|
+ self.veditId = id
|
|
|
+ self.markerId = ev.target._leaflet_id
|
|
|
+ self.saveForm.name = ev.target.options.name
|
|
|
+ self.saveForm.icon = require(`./images/layers/${ev.target.options.typeId}.png`)
|
|
|
+ })
|
|
|
+ marker.on('dragend', function(ev) {
|
|
|
+ self.layer = ev.target
|
|
|
+ })
|
|
|
+ }
|
|
|
+ markers.addTo(this.map)
|
|
|
+ this.markerGroup = markers
|
|
|
+ if (markerList && markerList.length > 0) {
|
|
|
+ for (let i = 0; i < markerList.length; i++) {
|
|
|
+ drawMark({
|
|
|
+ // tip: `${markerList[i].jobactivityTitle}`,
|
|
|
+ icon: `project-${markerList[i].typeId}`,
|
|
|
+ coordinates: [markerList[i].jobactQywzwd, markerList[i].jobactQywzjd],
|
|
|
+ options: { id: markerList[i].veditId, typeId: markerList[i].typeId, name: markerList[i].jobactivityTitle }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
},
|
|
|
mapListener() {
|
|
|
const self = this
|
|
|
@@ -334,17 +336,14 @@ export default {
|
|
|
this.map.on('pm:remove', (e) => {
|
|
|
console.log(e, '移除')
|
|
|
})
|
|
|
- this.map.on('pm:globaldragmodetoggled', e => {
|
|
|
- console.log(e, '拖拽结束')
|
|
|
- })
|
|
|
- this.map.on('pm:rotateend', (e) => {
|
|
|
- console.log(e, 'rotateend')
|
|
|
- this.handleType = undefined
|
|
|
- })
|
|
|
- // this.map.on('contextmenu', () => {
|
|
|
- // // 取消所有状态
|
|
|
- // this.resetMapControl()
|
|
|
+ // this.map.on('pm:globaldragmodetoggled', e => {
|
|
|
+ // console.log(e, '拖拽结束')
|
|
|
// })
|
|
|
+ this.map.on('contextmenu', () => {
|
|
|
+ // 取消所有状态
|
|
|
+ this.map.pm.disableGlobalDragMode()
|
|
|
+ this.cancel()
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|