Skip to content

Commit

Permalink
fix: more fine-grained map data event
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Dec 3, 2024
1 parent 7229b95 commit 936843c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/teritorio-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ export class TeritorioCluster extends EventTarget {
this.unfoldedClusterRender = options?.unfoldedClusterRenderFn
this.unfoldedClusterMaxLeaves = options?.unfoldedClusterMaxLeaves || 7

// after the GeoJSON data is loaded, update markers on the screen and do so on every map move/moveend
map.on('data', (e: MapSourceDataEvent) => {
if (e.sourceId !== this.sourceId || !e.isSourceLoaded || e.sourceDataType === 'metadata')
return

this.#render()
// After the GeoJSON data is loaded, update markers on the screen and do so on every map moveend
map.on('sourcedata', (ev: MapSourceDataEvent) => {
if (ev.isSourceLoaded && ev.sourceId === this.sourceId && ev.sourceDataType !== 'metadata') {
this.#render()
}
})

map.on('moveend', this.#render)
Expand Down

0 comments on commit 936843c

Please sign in to comment.