This commit is contained in:
liuye
2023-08-17 15:21:12 +08:00
parent 17249c16fa
commit b8838d2171
2 changed files with 22 additions and 12 deletions

View File

@@ -229,7 +229,7 @@
/>
<div class="map-info" v-if="item.msgType == 'location'">
<div :id="`map${index}`" class="map-content"></div>
<div :id="item.mapId" class="map-content"></div>
<div class="address-text">
<p>{{ item.title }}</p>
<p>{{ item.address }}</p>
@@ -578,9 +578,9 @@ export default {
},
];
}
if (item.msgType == "location") {
this.initMap(item.lng, item.lat, item.zoom, index);
}
// if (item.msgType == "location") {
// this.initMap(item.lng, item.lat, item.zoom, index);
// }
if (item.msgType == "image") {
var image = new Image();
image.crossOrigin = '';
@@ -596,6 +596,13 @@ export default {
this.msgCurrent > 1
? [...res.data.records, ...this.msgList]
: res.data.records;
this.msgList.map((item, index) => {
if (item.msgType == "location") {
item.mapId = `map${index}`
this.initMap(item.lng, item.lat, item.zoom, item.mapId);
}
})
this.msgPages = res.data.pages || 2;
this.$nextTick(() => {
if (this.msgCurrent == 1) {
@@ -630,12 +637,12 @@ export default {
return dataURL;
},
initMap(lng, lat, zoom, index) {
initMap(lng, lat, zoom, mapId) {
AMapLoader.load({
key: "54a02a43d9828a8f9cd4f26fe281e74e",
version: "2.0",
}).then((AMap) => {
this.map = new AMap.Map(`map${index}`, {
this.map = new AMap.Map(mapId, {
resizeEnable: true,
zooms: [6, 20],
center: [lng, lat],

View File

@@ -229,7 +229,7 @@
/>
<div class="map-info" v-if="item.msgType == 'location'">
<div :id="`map${index}`" class="map-content"></div>
<div :id="item.mapId" class="map-content"></div>
<div class="address-text">
<p>{{ item.title }}</p>
<p>{{ item.address }}</p>
@@ -578,9 +578,6 @@ export default {
},
];
}
if (item.msgType == "location") {
this.initMap(item.lng, item.lat, item.zoom, index);
}
if (item.msgType == "image") {
var image = new Image();
image.crossOrigin = '';
@@ -596,6 +593,12 @@ export default {
this.msgCurrent > 1
? [...res.data.records, ...this.msgList]
: res.data.records;
this.msgList.map((item, index) => {
if (item.msgType == "location") {
item.mapId = `map${index}`
this.initMap(item.lng, item.lat, item.zoom, item.mapId);
}
})
this.msgPages = res.data.pages || 2;
this.$nextTick(() => {
if (this.msgCurrent == 1) {
@@ -630,12 +633,12 @@ export default {
return dataURL;
},
initMap(lng, lat, zoom, index) {
initMap(lng, lat, zoom, mapId) {
AMapLoader.load({
key: "54a02a43d9828a8f9cd4f26fe281e74e",
version: "2.0",
}).then((AMap) => {
this.map = new AMap.Map(`map${index}`, {
this.map = new AMap.Map(mapId, {
resizeEnable: true,
zooms: [6, 20],
center: [lng, lat],