diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b23226..f1e9849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [1.0.10] - 2023-09-29 + +### Changed + +- Extend `viewport` property to support `bounds` manipulation + ## [1.0.9] - 2023-09-25 ### Added diff --git a/package.json b/package.json index 721bf5a..010a38e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dash-leaflet", - "version": "1.0.9", + "version": "1.0.10", "description": "Dash Leaflet is a light wrapper around React-Leaflet. The syntax is similar to other Dash components, with naming conventions following the React-Leaflet API.", "main": "index.ts", "repository": { diff --git a/src/ts/components/MapContainer.tsx b/src/ts/components/MapContainer.tsx index a584347..f27ba4d 100644 --- a/src/ts/components/MapContainer.tsx +++ b/src/ts/components/MapContainer.tsx @@ -36,7 +36,21 @@ function EventSubscriber(props) { if(props.viewport === undefined){ return; } - let {transition, center, zoom, options} = props.viewport; + let {transition, center, zoom, options, bounds} = props.viewport; + // TODO: Should bounds take precedence? + if(bounds){ + switch (transition) { + case 'flyToBounds': + map.flyToBounds(bounds, options) + return; + case 'panInsideBounds': + map.panInsideBounds(bounds, options) + return; + default: + map.fitBounds(bounds, options) + } + return; + } if(!center){ center = map.getCenter(); } @@ -79,17 +93,24 @@ type Props = Modify