Skip to content

Commit

Permalink
Fix multiple object show
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed May 7, 2024
1 parent e4d61cf commit 533548c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions web/static/map/Osmose.Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class OsmoseMarker {
}, 100)
}

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

ExternalVueAppEvent.$emit('load-doc', {
Expand All @@ -115,20 +115,24 @@ export default class OsmoseMarker {
if (data.elems_id) {
let shift = -1
this.clearOsmLayer()
data.elems.forEach((elem) => {
fetch(
elem.type === 'node'
? `${this._remoteUrlRead}api/0.6/node/${elem.id}`
: `${this._remoteUrlRead}api/0.6/${elem.type}/${elem.id}/full`
)
.then((response) => response.text())
.then((str) =>
new window.DOMParser().parseFromString(str, 'text/xml')
const features = await Promise.all(
data.elems.map((elem) =>
fetch(
elem.type === 'node'
? `${this._remoteUrlRead}api/0.6/node/${elem.id}`
: `${this._remoteUrlRead}api/0.6/${elem.type}/${elem.id}/full`
)
.then((xml) => {
const geojson = osm2geojson(xml)
this._map.getSource('osm').setData(geojson)
})
.then((response) => response.text())
.then((str) =>
new window.DOMParser().parseFromString(str, 'text/xml')
)
.then((xml) => osm2geojson(xml).features)
)
)
console.error(features.flat())
this._map.getSource('osm').setData({
type: 'FeatureCollection',
features: features.flat(),
})
}
}
Expand Down

0 comments on commit 533548c

Please sign in to comment.