diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d14cc2..be79580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index d2c3a1d..b8c8526 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", @@ -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", diff --git a/src/lib/components/Map.react.js b/src/lib/components/Map.react.js index 629c452..f69f9b7 100644 --- a/src/lib/components/Map.react.js +++ b/src/lib/components/Map.react.js @@ -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 ; }