Skip to content

Commit 533548c

Browse files
committed
Fix multiple object show
1 parent e4d61cf commit 533548c

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

web/static/map/Osmose.Marker.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default class OsmoseMarker {
104104
}, 100)
105105
}
106106

107-
_setPopup(data): void {
107+
async _setPopup(data): void {
108108
data.elems_id = data.elems.map((elem) => elem.type + elem.id).join(',')
109109

110110
ExternalVueAppEvent.$emit('load-doc', {
@@ -115,20 +115,24 @@ export default class OsmoseMarker {
115115
if (data.elems_id) {
116116
let shift = -1
117117
this.clearOsmLayer()
118-
data.elems.forEach((elem) => {
119-
fetch(
120-
elem.type === 'node'
121-
? `${this._remoteUrlRead}api/0.6/node/${elem.id}`
122-
: `${this._remoteUrlRead}api/0.6/${elem.type}/${elem.id}/full`
123-
)
124-
.then((response) => response.text())
125-
.then((str) =>
126-
new window.DOMParser().parseFromString(str, 'text/xml')
118+
const features = await Promise.all(
119+
data.elems.map((elem) =>
120+
fetch(
121+
elem.type === 'node'
122+
? `${this._remoteUrlRead}api/0.6/node/${elem.id}`
123+
: `${this._remoteUrlRead}api/0.6/${elem.type}/${elem.id}/full`
127124
)
128-
.then((xml) => {
129-
const geojson = osm2geojson(xml)
130-
this._map.getSource('osm').setData(geojson)
131-
})
125+
.then((response) => response.text())
126+
.then((str) =>
127+
new window.DOMParser().parseFromString(str, 'text/xml')
128+
)
129+
.then((xml) => osm2geojson(xml).features)
130+
)
131+
)
132+
console.error(features.flat())
133+
this._map.getSource('osm').setData({
134+
type: 'FeatureCollection',
135+
features: features.flat(),
132136
})
133137
}
134138
}

0 commit comments

Comments
 (0)