Skip to content

Commit

Permalink
fix: cluster not found during async call #39
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Dec 2, 2024
1 parent 9d8e310 commit 2c9f161
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@
}

const removeData = () => {
const source = map.getSource('earthquakes')
if(teritorioCluster.ticking)
return

const source = map.getSource('earthquakes')

source.setData({
type: 'FeatureCollection',
features: geojson.features
Expand Down
9 changes: 7 additions & 2 deletions src/teritorio-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,13 @@ export class TeritorioCluster extends EventTarget {
// Get cluster's leaves
if (feature.properties.cluster) {
const source = this.map.getSource(this.sourceId) as GeoJSONSource
const leaves = await source.getClusterLeaves(Number.parseInt(id), feature.properties.point_count, 0) as MapGeoJSONFeature[]
this.clusterLeaves.set(id, leaves)

Check failure on line 346 in src/teritorio-cluster.ts

View workflow job for this annotation

GitHub Actions / 🛠️ Setup Development Environment

Trailing spaces not allowed
try {
const leaves = await source.getClusterLeaves(Number.parseInt(id), feature.properties.point_count, 0) as MapGeoJSONFeature[]
this.clusterLeaves.set(id, leaves)
} catch(error) {

Check failure on line 350 in src/teritorio-cluster.ts

View workflow job for this annotation

GitHub Actions / 🛠️ Setup Development Environment

Closing curly brace appears on the same line as the subsequent block

Check failure on line 350 in src/teritorio-cluster.ts

View workflow job for this annotation

GitHub Actions / 🛠️ Setup Development Environment

Expected space(s) after "catch"
console.error(error)
}
}
}

Expand Down

0 comments on commit 2c9f161

Please sign in to comment.