const leftNavsData = {
|
state: {
|
addIconsLayerIconstate: false,
|
addIconsLayerIconLayer: null,
|
addIconsLayerIconPopup: false, // 控制编辑窗口显影
|
addIconsLayerIconPosition: [] // 发送坐标
|
},
|
actions: {
|
chouseAddIconsLayerIcon ({
|
state,
|
commit,
|
dispatch
|
}, val) {
|
// 加载图层
|
commit('createAddIconsLayerIconLayer', {
|
viewer: val.viewer
|
})
|
// 重置事件
|
state.addIconsLayerIconstate = false
|
commit('set_closeMapClick', true) // 关闭其他操作
|
// 监听鼠标移动
|
val.viewer.on(global.DC.MouseEventType.MOUSE_MOVE, (e) => {
|
if (state.addIconsLayerIconstate) { // 事件完成
|
return
|
}
|
commit('addIconsLayerIconmoveMessage', {
|
e: e,
|
b: '点击确认标注位置',
|
viewer: val.viewer
|
})
|
})
|
val.viewer.once(global.DC.MouseEventType.CLICK, (e) => {
|
commit('addIconsLayerIconmoveMessage', { // 取消tip
|
e: e,
|
b: '',
|
viewer: val.viewer
|
})
|
dispatch('pcFlyView', { // 飞入位置
|
jd: e.wgs84SurfacePosition.lng,
|
wd: +e.wgs84SurfacePosition.lat + 0.0002,
|
viewer: val.viewer
|
})
|
// 完成选点操作
|
state.addIconsLayerIconstate = true
|
// commit("set_closeMapClick", false); //开启其他操作
|
if (val.fn) {
|
const lnglat = [e.wgs84SurfacePosition.lng,
|
e.wgs84SurfacePosition.lat
|
]
|
val.fn(lnglat)
|
}
|
})
|
},
|
addIconsLayerIcon ({
|
state,
|
commit,
|
dispatch
|
}, val) {
|
const divIcon = new global.DC.DivIcon(
|
new global.DC.Position(
|
Number(val.lnglat[0]),
|
Number(val.lnglat[1]),
|
0
|
),
|
`
|
<div class="tag-entitys-box">
|
<div class="tag-content">
|
${val.name || '我的标签'}
|
</div>
|
<div class="tag-angle-content">
|
<img src="https://map.hit.edu.cn/images/tarrow_xq.png">
|
</div>
|
</div>
|
`
|
)
|
state.addIconsLayerIconLayer.addOverlay(divIcon)
|
// 打开编辑窗口弹窗
|
new global.DC.DivForms(val.viewer, {
|
domId: 'leftNavsAdd',
|
position: [
|
global.DC.Transform.transformWGS84ToCartesian(
|
new global.DC.Position(
|
Number(val.lnglat[0]),
|
Number(val.lnglat[1]),
|
Number(0)
|
)
|
)
|
]
|
})
|
commit('SET_addIconsLayerIconPosition', val.lnglat)
|
commit('SET_addIconsLayerIconPopup', true)
|
}
|
},
|
mutations: {
|
createAddIconsLayerIconLayer (state, val) {
|
if (state.addIconsLayerIconLayer == null) {
|
state.addIconsLayerIconLayer = new global.DC.HtmlLayer('addIconsLayerIconLayer')
|
val.viewer.addLayer(state.addIconsLayerIconLayer)
|
}
|
if (val.clear) {
|
state.addIconsLayerIconLayer.clear()
|
}
|
},
|
addIconsLayerIconmoveMessage (state, val) {
|
if (val.b == '') {
|
val.viewer.tooltip.enable = false
|
} else {
|
val.viewer.tooltip.enable = true
|
val.viewer.tooltip.showAt(val.e.windowPosition, val.b)
|
}
|
},
|
SET_addIconsLayerIconPopup (state, addIconsLayerIconPopup) {
|
state.addIconsLayerIconPopup = addIconsLayerIconPopup
|
if (!state.addIconsLayerIconPopup) { // 关闭即关闭图层 并刷新标签
|
if (state.addIconsLayerIconLayer) {
|
state.addIconsLayerIconLayer.clear()
|
state.addIconsLayerIconLayer.remove()
|
state.addIconsLayerIconLayer = null
|
}
|
}
|
},
|
SET_addIconsLayerIconPosition (state, addIconsLayerIconPosition) {
|
state.addIconsLayerIconPosition = addIconsLayerIconPosition
|
}
|
}
|
}
|
|
export default leftNavsData
|