fix: keep map canvas synchronized with workspace
This commit is contained in:
@@ -175,6 +175,10 @@ function GeoMap({
|
||||
zoom: 11,
|
||||
attributionControl: false,
|
||||
})
|
||||
const resizeObserver = new ResizeObserver(() => {
|
||||
map.resize()
|
||||
})
|
||||
resizeObserver.observe(containerRef.current)
|
||||
map.addControl(new maplibregl.NavigationControl(), 'top-right')
|
||||
map.addControl(
|
||||
new maplibregl.AttributionControl({
|
||||
@@ -196,6 +200,7 @@ function GeoMap({
|
||||
})
|
||||
}
|
||||
map.on('load', () => {
|
||||
map.resize()
|
||||
setMapStyleReady(true)
|
||||
emitViewport()
|
||||
})
|
||||
@@ -274,6 +279,7 @@ function GeoMap({
|
||||
mapRef.current = map
|
||||
|
||||
return () => {
|
||||
resizeObserver.disconnect()
|
||||
map.remove()
|
||||
mapRef.current = null
|
||||
setMapStyleReady(false)
|
||||
|
||||
Reference in New Issue
Block a user