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