Store center/zoom in fire map
This commit is contained in:
parent
735dd55531
commit
35ba215834
3 changed files with 19 additions and 6 deletions
|
|
@ -13,6 +13,7 @@ import { Trans, translate } from 'react-i18next';
|
|||
import { Map } from 'react-leaflet';
|
||||
import Control from 'react-leaflet-control';
|
||||
import _ from 'lodash';
|
||||
import store from 'store';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.css';
|
||||
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js';
|
||||
|
|
@ -82,7 +83,8 @@ class FiresMap extends React.Component {
|
|||
const bounds = this.getMap().getBounds();
|
||||
// console.log(bounds);
|
||||
mapSize.set([bounds.getNorthEast(), bounds.getSouthWest()]);
|
||||
/*
|
||||
store.set('firesmap_center', viewport.center);
|
||||
store.set('firesmap_zoom', viewport.zoom);
|
||||
if (viewport.center === this.state.viewport.center &&
|
||||
viewport.zoom === this.state.viewport.zoom) {
|
||||
// Do nothing, in same point
|
||||
|
|
@ -90,7 +92,7 @@ class FiresMap extends React.Component {
|
|||
}
|
||||
zoom.set(viewport.zoom);
|
||||
center.set(viewport.center);
|
||||
this.setState({ viewport }); */
|
||||
this.setState({ viewport });
|
||||
}
|
||||
|
||||
centerOnUserLocation(viewport) {
|
||||
|
|
@ -279,9 +281,14 @@ let init = true;
|
|||
|
||||
export default translate([], { wait: true })(withTracker(() => {
|
||||
let subscription;
|
||||
|
||||
const centerStored = store.get('firesmap_center');
|
||||
const zoomStored = store.get('firesmap_zoom');
|
||||
zoom.set(zoomStored || 8);
|
||||
|
||||
Meteor.autorun(() => {
|
||||
if (geolocation.get() && init) {
|
||||
center.set(geolocation.get());
|
||||
if ((centerStored || geolocation.get()) && init) {
|
||||
center.set(centerStored || geolocation.get());
|
||||
// console.log(`Geolocation ${geolocation.get()}`);
|
||||
init = false;
|
||||
}
|
||||
|
|
@ -328,7 +335,7 @@ export default translate([], { wait: true })(withTracker(() => {
|
|||
firealerts: fireAlerts,
|
||||
falsePositives,
|
||||
lastCheck: lastCheck ? lastCheck.value : null,
|
||||
center: geolocation.get(),
|
||||
center: center.get(),
|
||||
zoom: zoom.get()
|
||||
};
|
||||
})(FiresMap));
|
||||
|
|
|
|||
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -11140,6 +11140,11 @@
|
|||
"resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
|
||||
"integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks="
|
||||
},
|
||||
"store": {
|
||||
"version": "2.0.12",
|
||||
"resolved": "https://registry.npmjs.org/store/-/store-2.0.12.tgz",
|
||||
"integrity": "sha1-jFNOKguDH3K3X8XxEZhXxE711ZM="
|
||||
},
|
||||
"string-length": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/string-length/-/string-length-2.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -69,7 +69,8 @@
|
|||
"react-router-hash-link": "^1.1.1",
|
||||
"reactstrap": "^5.0.0-alpha.3",
|
||||
"simpl-schema": "^0.3.2",
|
||||
"simple-line-icons": "^2.4.1"
|
||||
"simple-line-icons": "^2.4.1",
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "^21.2.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue