Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Fix circuit not highlighting on intial load

Russ Garrett93687aff57c5
diff --git a/web/src/circuit/circuitinspector.ts b/web/src/circuit/circuitinspector.ts
index 36d1f0c..245fe74 100644
--- a/web/src/circuit/circuitinspector.ts
+++ b/web/src/circuit/circuitinspector.ts
@@ -120,11 +120,11 @@ export class CircuitInspector {
})
}
- updateData(data: GeoJSON.GeoJSON) {
- if (!this._map.loaded()) {
- this._map.on('load', () => {
- this.updateData(data)
- })
+ async updateData(data: GeoJSON.GeoJSON) {
+ if (!this._map.isStyleLoaded()) {
+ // Spin wait for style to be loaded.
+ setTimeout(() => this.updateData(data), 100)
+ return
}
this._bbox = data['bbox']
const source: GeoJSONSource = this._map.getSource('circuit_highlight')!