From fde04bb77f65b29bdd671806349927397e543c48 Mon Sep 17 00:00:00 2001 From: vjrj Date: Mon, 12 Feb 2018 13:07:09 +0100 Subject: [PATCH] FiresMap issue with init --- imports/ui/pages/FiresMap/FiresMap.js | 246 +++++++++++++------------- 1 file changed, 124 insertions(+), 122 deletions(-) diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js index 8cbfb45..ffbf2f2 100644 --- a/imports/ui/pages/FiresMap/FiresMap.js +++ b/imports/ui/pages/FiresMap/FiresMap.js @@ -81,19 +81,21 @@ class FiresMap extends React.Component { handleViewportChange(viewport) { console.log(`Viewport changed: ${JSON.stringify(viewport)}`); - 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 - return; + if (this.fireMap) { + 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 + return; + } + zoom.set(viewport.zoom); + center.set(viewport.center); + this.setState({ viewport }); } - zoom.set(viewport.zoom); - center.set(viewport.center); - this.setState({ viewport }); } centerOnUserLocation(viewport) { @@ -149,117 +151,117 @@ class FiresMap extends React.Component { ref={(divElement) => { this.divElement = divElement; }} > { !isHome() && - - {title} - - } - {this.props.loading || !this.props.subsready ? - - - - : ''} -

Fuegos activos

- - -

- { (this.props.activefires.length + this.props.firealerts.length) === 0 ? - No hay fuegos activos en esta zona del mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo. Datos actualizados . : - En rojo, {{ count: this.props.activefires.length + this.props.firealerts.length }} fuegos activos en el mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo por la NASA. Datos actualizados . - } -

- {isNotHomeAndMobile && -

En naranja, los fuegos notificados por nuestros usuarios/as recientemente.

} - - - {isNotHomeAndMobile && + + {title} + + } + {this.props.loading || !this.props.subsready ? + + + + : ''} +

Fuegos activos

+ + +

+ { (this.props.activefires.length + this.props.firealerts.length) === 0 ? + No hay fuegos activos en esta zona del mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo. Datos actualizados . : + En rojo, {{ count: this.props.activefires.length + this.props.firealerts.length }} fuegos activos en el mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo por la NASA. Datos actualizados . + } +

+ {isNotHomeAndMobile && +

En naranja, los fuegos notificados por nuestros usuarios/as recientemente.

} + + + {isNotHomeAndMobile && + + this.setShowSubsUnion(e.target.checked)}> + Resaltar en verde el área vigilada por nuestros usuarios/as (*) + + {(this.state.viewport.zoom >= MAXZOOM) && + this.useMarkers(e.target.checked)}> + Resaltar los fuegos con un marcador + } + } +

+ { this.state.viewport.zoom >= MAXZOOMREACTIVE ? + Los fuegos activos se actualizan en tiempo real. : + Haga zoom en una zona de su interés si quiere que los fuegos se actualicen en tiempo real. + } + +

+ +
+ {/* https://github.com/CliffCloud/Leaflet.Sleep */} + { + this.fireMap = map; + this.handleLeafletLoad(map); + }} + className="firesmap-leaflet-container" + animate + minZoom={5} + center={this.props.center} + zoom={this.props.zoom} + preferCanvas + onClick={this.onClickReset} + viewport={this.state.viewport} + onViewportChanged={this.onViewportChanged} + sleep={isHome() && !isChrome} + sleepTime={10750} + wakeTime={750} + sleepNote + hoverToWake={false} + wakeMessage={this.props.t('Pulsa para activar')} + wakeMessageTouch={this.props.t('Pulsa para activar')} + sleepOpacity={0.6} + > + {/* http://wiki.openstreetmap.org/wiki/Tile_servers */} + {!this.props.loading && - this.setShowSubsUnion(e.target.checked)}> - Resaltar en verde el área vigilada por nuestros usuarios/as (*) - - {(this.state.viewport.zoom >= MAXZOOM) && - this.useMarkers(e.target.checked)}> - Resaltar los fuegos con un marcador - } - } -

- { this.state.viewport.zoom >= MAXZOOMREACTIVE ? - Los fuegos activos se actualizan en tiempo real. : - Haga zoom en una zona de su interés si quiere que los fuegos se actualicen en tiempo real. - } - -

- -
- {/* https://github.com/CliffCloud/Leaflet.Sleep */} - { - this.fireMap = map; - this.handleLeafletLoad(map); - }} - className="firesmap-leaflet-container" - animate - minZoom={5} - center={this.props.center} - zoom={this.props.zoom} - preferCanvas - onClick={this.onClickReset} - viewport={this.state.viewport} - onViewportChanged={this.onViewportChanged} - sleep={isHome() && !isChrome} - sleepTime={10750} - wakeTime={750} - sleepNote - hoverToWake={false} - wakeMessage={this.props.t('Pulsa para activar')} - wakeMessageTouch={this.props.t('Pulsa para activar')} - sleepOpacity={0.6} - > - {/* http://wiki.openstreetmap.org/wiki/Tile_servers */} - {!this.props.loading && - - = MAXZOOM} - useMarkers={this.state.useMarkers} - nasa={false} - falsePositives - /> - = MAXZOOM} - useMarkers={this.state.useMarkers} - nasa - falsePositives={false} - /> - - } - - - - this.centerOnUserLocation(viewport)} onlyIcon {... this.props} /> - - - - - -

(*)Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.

- -
- { !isHome() && - - } + = MAXZOOM} + useMarkers={this.state.useMarkers} + nasa={false} + falsePositives + /> + = MAXZOOM} + useMarkers={this.state.useMarkers} + nasa + falsePositives={false} + /> + + } + + + + this.centerOnUserLocation(viewport)} onlyIcon {... this.props} /> + + + + + +

(*)Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.

+ +
+ { !isHome() && + + } ); }