Skip to content

Commit

Permalink
Merge pull request #203 from emilhe/1.0.10
Browse files Browse the repository at this point in the history
Prepare version 1.0.10
  • Loading branch information
emilhe authored Sep 29, 2023
2 parents a7efdf8 + 1a9b2ff commit bb252af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
29 changes: 25 additions & 4 deletions src/ts/components/MapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -79,17 +93,24 @@ type Props = Modify<MapContainerProps, {
invalidateSize?: string | number | object;

/**
* This property can be used to manipulate the viewport after initializing the map. [DL]
* This property can be used to manipulate the viewport after initializing the map. Set either "center"/"zoom",
* or bounds. If both are set, "bounds" takes precedence. Default value for transition is "setView" for "center"/
* "zoom", and "fitBounds" for "bounds". [DL]
*/
viewport?: {
center?: number[],
zoom?: number
transition?: "flyTo" | "panTo" | "setView"
transition?: "flyTo" | "panTo" | "setView" | "fitBounds" | "flyToBounds" | "panInsideBounds"
bounds?: number[][]
options?: {
animate?: boolean,
duration?: number,
easeLinearity?: number,
noMoveStart?: boolean
noMoveStart?: boolean,
// These are for bounds panning
paddingTopLeft?: number[],
paddingBottomRight?: number[],
padding?: number[],
}
};

Expand Down

0 comments on commit bb252af

Please sign in to comment.