大屏地图标记弹窗完成

This commit is contained in:
aixianling
2023-04-13 15:59:28 +08:00
parent 62c927746b
commit 1bd2bf44bb
3 changed files with 20 additions and 11 deletions

View File

@@ -165,24 +165,23 @@ export default {
let {lib: AMap, map} = this let {lib: AMap, map} = this
this.timer && clearInterval(this.timer) this.timer && clearInterval(this.timer)
if (AMap && map) { if (AMap && map) {
let infoWin = new AMap.InfoWindow({content: ""}) const infoWin = new AMap.InfoWindow({isCustom: true, content: ""})
map.clearMap() map.clearMap()
this.values.filter(e => e.lng).map(e => { map.on('click', () => infoWin.close())
this.values.filter(e => e.lng).map((e) => {
const {icon = "https://cdn.cunwuyun.cn/dvcp/h5/Location2.png"} = e
return new AMap.Marker({ return new AMap.Marker({
map, map,
content: e.content || `<div class="marker ${this.data.alwaysShow ? 'showLabel' : ''}"> content: e.content || `<div class="marker ${this.data.alwaysShow ? 'showLabel' : ''}">
<img src="${e.icon}"/> <img src="${icon}"/>
<span>${e.label}</span> <span>${e.label}</span>
</div>`, </div>`,
position: [e.lng, e.lat] position: [e.lng, e.lat]
}).on('click', () => { }).on('click', () => {
if (!!e.openWin || e.infoWindowHtml) { if (!!e.openWin || e.infoWindowHtml) {
map.clearInfoWindow() map.clearInfoWindow()
infoWin.setContent(e.infoWindowHtml || infoWin.setContent(e.infoWindowHtml ? `<div class="mapInfoWin">${e.infoWindowHtml}</div>` :
[`<div class="infoWin">`, [`<div class="infoWin">`, `<b>${e.label}</b>`, '</div>'].join('')
`<b>${e.label}</b>`,
'</div>'
].join('')
) )
infoWin.open(map, [e.lng, e.lat]) infoWin.open(map, [e.lng, e.lat])
} }
@@ -275,5 +274,16 @@ export default {
white-space: nowrap; white-space: nowrap;
} }
} }
:deep(.mapInfoWin) {
padding: 16px 8px;
max-width: 800px;
background-color: rgba(255, 255, 255, 0.25);
backdrop-filter: blur(6px);
border: 1px solid rgba(255, 255, 255, 0.18);
box-shadow: rgba(142, 142, 142, 0.19) 0px 6px 15px 0px;
border-radius: 4px;
color: rgba(255, 255, 255, 0.75);
}
} }
</style> </style>

View File

@@ -136,7 +136,7 @@
</el-form-item> </el-form-item>
</div> </div>
<el-form-item label="弹窗内容"> <el-form-item label="弹窗内容">
<ai-editor v-model="form.winInfo" :instance="instance"/> <ai-editor v-model="form.infoWindowHtml" :instance="instance"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
</ai-dialog> </ai-dialog>

View File

@@ -28,8 +28,7 @@ module.exports = {
.add(path.resolve(__dirname, 'examples')) .add(path.resolve(__dirname, 'examples'))
.add(path.resolve(__dirname, 'ui')) .add(path.resolve(__dirname, 'ui'))
.end().use('babel').loader('babel-loader').tap(options => options); .end().use('babel').loader('babel-loader').tap(options => options);
config.plugins.delete("friendly-errors"); config.plugin("limit").use(require("webpack/lib/optimize/LimitChunkCountPlugin"), [{maxChunks: 10}]).tap(options => options)
config.plugin("limit").use(require("webpack/lib/optimize/LimitChunkCountPlugin"), [{maxChunks: 5}]).tap(options => options)
}, },
devServer: { devServer: {
host: '0.0.0.0', //主机地址 host: '0.0.0.0', //主机地址