Skip to content

Commit

Permalink
Merge pull request #63 from thedirtyfew/bounds_fix
Browse files Browse the repository at this point in the history
Getting ready for 0.1.12 release.
  • Loading branch information
emilhe authored Dec 12, 2020
2 parents 22c2ce9 + aa185b0 commit 801e329
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 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.

## [0.1.12] - 2020-12-12

### Changed

- Regression (bounds passed from Dash not applied) due to fix in 0.1.11 [fixed](https://github.com/thedirtyfew/dash-leaflet/issues/62)

## [0.1.11] - 2020-04-12

### Changed
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash_leaflet",
"version": "0.1.11",
"version": "0.1.12",
"description": "Leaflet component for Dash",
"main": "build/index.js",
"scripts": {
Expand All @@ -25,16 +25,18 @@
"dependencies": {
"chroma-js": "^2.1.0",
"d3": "^5.9.2",
"dash-extensions": "0.0.1",
"electron": "^11.0.3",
"geobuf": "^3.0.1",
"geotiff": "^1.0.0-beta.6",
"immutability-helper": "^3.1.1",
"jszip": "^3.5.0",
"leaflet": "^1.6.0",
"leaflet-easybutton": "^2.4.0",
"leaflet-measure": "^3.1.0",
"leaflet-polylinedecorator": "^1.6.0",
"leaflet.locatecontrol": "^0.71.1",
"leaflet.markercluster": "^1.4.1",
"leaflet-measure": "^3.1.0",
"lzma": "^2.3.2",
"pbf": "^3.2.1",
"proj4": "^2.5.0",
Expand All @@ -43,8 +45,7 @@
"react-leaflet": "^2.6.3",
"react-leaflet-markercluster": "^2.0.0-rc3",
"regenerator-runtime": "^0.13.5",
"supercluster": "^7.1.0",
"dash-extensions": "0.0.1"
"supercluster": "^7.1.0"
},
"devDependencies": {
"@babel/core": "^7.4.5",
Expand Down
30 changes: 15 additions & 15 deletions src/lib/components/Map.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ export default class Map extends Component {
};
nProps.whenReady = () => {
const el = this.myRef.current;
if (el) {
const bounds = el.leafletElement.getBounds();
nProps.setProps({bounds: [[bounds.getSouth(), bounds.getWest()], [bounds.getNorth(), bounds.getEast()]]})
// Only update on initial load, i.e. when nProps.bounds has not yet been set.
if (!el || nProps.bounds !== undefined) {
return
}
// Update bounds.
const bounds = el.leafletElement.getBounds();
nProps.setProps({bounds: [[bounds.getSouth(), bounds.getWest()], [bounds.getNorth(), bounds.getEast()]]})
}
// TODO: Does this affect performance? Maybe make it optional.
nProps.onViewportChanged = (e) => {
const el = this.myRef.current;
if (el) {
const bounds = el.leafletElement.getBounds();
nProps.setProps({
viewport: e, zoom: e.zoom, center: e.center,
bounds: [[bounds.getSouth(), bounds.getWest()], [bounds.getNorth(), bounds.getEast()]]
})
} else {
nProps.setProps({
viewport: e, zoom: e.zoom, center: e.center,
})
// If the element is not there, skip the update.
if (!el) {
return
}
// Update bounds and view port.
const bounds = el.leafletElement.getBounds();
nProps.setProps({
viewport: e, zoom: e.zoom, center: e.center,
bounds: [[bounds.getSouth(), bounds.getWest()], [bounds.getNorth(), bounds.getEast()]]
})
};
// Setup CRS.
nProps.crs = L.CRS[nProps.crs]
// Strip bounds. It can confuse maps between tabs.
delete nProps.bounds
// Render the leaflet component.
return <LeafletMap {...nProps} ref={this.myRef}/>;
}
Expand Down

0 comments on commit 801e329

Please sign in to comment.