diff --git a/modules/react-mapbox/src/mapbox/mapbox.ts b/modules/react-mapbox/src/mapbox/mapbox.ts index bb40fd7c3..ce92168aa 100644 --- a/modules/react-mapbox/src/mapbox/mapbox.ts +++ b/modules/react-mapbox/src/mapbox/mapbox.ts @@ -90,7 +90,7 @@ const DEFAULT_SETTINGS = { maxZoom: 22, minPitch: 0, maxPitch: 85, - maxBounds: [-180, -85.051129, 180, 85.051129], + maxBounds: null, projection: 'mercator', renderWorldCopies: true }; diff --git a/modules/react-maplibre/src/maplibre/maplibre.ts b/modules/react-maplibre/src/maplibre/maplibre.ts index cd3e35205..4043c20e6 100644 --- a/modules/react-maplibre/src/maplibre/maplibre.ts +++ b/modules/react-maplibre/src/maplibre/maplibre.ts @@ -104,7 +104,7 @@ export type MaplibreProps = Partial & const DEFAULT_STYLE = {version: 8, sources: {}, layers: []} as StyleSpecification; const DEFAULT_SETTINGS = { - maxBounds: [-180, -85.051129, 180, 85.051129], + maxBounds: null, projection: 'mercator', renderWorldCopies: true }; diff --git a/modules/react-maplibre/test/components/map.spec.jsx b/modules/react-maplibre/test/components/map.spec.jsx index f9982c904..999d63f57 100644 --- a/modules/react-maplibre/test/components/map.spec.jsx +++ b/modules/react-maplibre/test/components/map.spec.jsx @@ -156,6 +156,27 @@ test('Map resets camera constraints when reusing a map', async () => { } }); +test('Map resets maxBounds when the prop is removed', async () => { + const root = createRoot(document.createElement('div')); + const mapRef = {current: null}; + const maxBounds = [-120, 20, -80, 50]; + + await act(() => root.render()); + await waitForMapLoad(mapRef); + + const applied = mapRef.current.getMaxBounds(); + expect(applied.getWest()).toBe(-120); + expect(applied.getSouth()).toBe(20); + expect(applied.getEast()).toBe(-80); + expect(applied.getNorth()).toBe(50); + + await act(() => root.render()); + + expect(mapRef.current.getMaxBounds()).toBe(null); + + await act(() => root.unmount()); +}); + test('Map#uncontrolled', async () => { await actUntil(resolveTest => { const root = createRoot(document.createElement('div'));