diff --git a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js
index 167bcfa..ebcd9a0 100644
--- a/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js
+++ b/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js
@@ -1,27 +1,28 @@
+/* global Geolocation */
import React from 'react';
-import './CenterInMyPosition.scss';
+import PropTypes from 'prop-types';
+import { Tracker } from 'meteor/tracker';
+import { ReactiveVar } from 'meteor/reactive-var';
import { Button } from 'react-bootstrap';
import { translate } from 'react-i18next';
+import './CenterInMyPosition.scss';
class CenterInMyPosition extends React.Component {
- constructor(props) {
- super(props);
- }
-
- onClick = (event) => {
+ onClick() {
// this.props.onClick(event);
// https://atmospherejs.com/mdg/geolocation
// only with SSL:
// https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
+ console.log('Center');
// https://stackoverflow.com/questions/31608579/somethings-wrong-with-my-meteor-geolocation-functions
- var userGeoLocation = new ReactiveVar(null);
- var self = this;
- Tracker.autorun(function (computation) {
+ const userGeoLocation = new ReactiveVar(null);
+ const self = this;
+ Tracker.autorun((computation) => {
userGeoLocation.set(Geolocation.latLng());
if (userGeoLocation.get()) {
- //stop the tracker if we got something
- var viewport = {
+ // stop the tracker if we got something
+ const viewport = {
center: [userGeoLocation.get().lat, userGeoLocation.get().lng],
zoom: 11
};
@@ -35,11 +36,14 @@ class CenterInMyPosition extends React.Component {
render() {
return (
-
- )
+ );
}
}
-export default translate([], { wait: true }) (CenterInMyPosition);
+CenterInMyPosition.propTypes = {
+ t: PropTypes.func.isRequired
+};
+
+export default translate([], { wait: true })(CenterInMyPosition);
diff --git a/imports/ui/pages/FiresMap/FiresMap.js b/imports/ui/pages/FiresMap/FiresMap.js
index 1023c3e..b2ed7eb 100644
--- a/imports/ui/pages/FiresMap/FiresMap.js
+++ b/imports/ui/pages/FiresMap/FiresMap.js
@@ -1,97 +1,123 @@
-import React, {Component} from 'react';
-import { Row, Col, Checkbox } from 'react-bootstrap';
+/* global L Counter */
+/* eslint-disable import/no-absolute-path */
+/* eslint-disable react/jsx-indent-props */
+/* eslint-disable react/jsx-indent */
+import React from 'react';
import PropTypes from 'prop-types';
+import { Row, Col, Checkbox } from 'react-bootstrap';
import { Meteor } from 'meteor/meteor';
-import { Trans, translate } from 'react-i18next';
-import 'leaflet/dist/leaflet.css';
-import { Circle, CircleMarker, Map, Marker, Popup, TileLayer, PropTypes as MapPropTypes } from 'react-leaflet';
-import ActiveFiresCollection from '../../../api/ActiveFires/ActiveFires';
-import FireAlertsCollection from '../../../api/FireAlerts/FireAlerts';
-import UserSubsToFiresCollection from '../../../api/Subscriptions/Subscriptions';
-import CenterInMyPosition from '/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js';
+import { ReactiveVar } from 'meteor/reactive-var';
import { withTracker } from 'meteor/react-meteor-data';
-import 'leaflet-sleep/Leaflet.Sleep.js';
-import Loading from '../../components/Loading/Loading';
-import './FiresMap.scss';
+import { Trans, translate } from 'react-i18next';
+import { Circle, CircleMarker, Map, Marker, TileLayer, PropTypes as MapPropTypes } from 'react-leaflet';
import Leaflet from 'leaflet';
import LGeo from 'leaflet-geodesy';
import union from '@turf/union';
+import _ from 'lodash';
+import 'leaflet/dist/leaflet.css';
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.css';
import 'leaflet-graphicscale/dist/Leaflet.GraphicScale.min.js';
-import _ from 'lodash';
+import 'leaflet-sleep/Leaflet.Sleep.js';
+import geolocation from '/imports/startup/client/geolocation';
+import CenterInMyPosition from '/imports/ui/components/CenterInMyPosition/CenterInMyPosition.js';
+import ActiveFiresCollection from '../../../api/ActiveFires/ActiveFires';
+import FireAlertsCollection from '../../../api/FireAlerts/FireAlerts';
+import UserSubsToFiresCollection from '../../../api/Subscriptions/Subscriptions';
+import Loading from '../../components/Loading/Loading';
+import './FiresMap.scss';
+
+const DEF_LAT = 35.159028;
+const DEF_LNG = -46.738057;
+const DEFAULT_VIEWPORT = {
+ center: [DEF_LAT, DEF_LNG], // a point in the sea
+ zoom: 8
+};
+const zoom = new ReactiveVar(8);
+const lat = new ReactiveVar(DEF_LAT);
+const lng = new ReactiveVar(DEF_LNG);
+const height = new ReactiveVar(400);
+const width = new ReactiveVar(400);
// https://stackoverflow.com/questions/35394577/leaflet-js-union-merge-circles
function unify(polyList) {
- for (var i = 0; i < polyList.length; ++i) {
- if (i == 0) {
- var unionTemp = polyList[i].toGeoJSON();
+ let unionTemp;
+ for (let i = 0; i < polyList.length; i += 1) {
+ if (i === 0) {
+ unionTemp = polyList[i].toGeoJSON();
} else {
- unionTemp =union(unionTemp, polyList[i].toGeoJSON());
+ unionTemp = union(unionTemp, polyList[i].toGeoJSON());
}
}
return L.geoJson(unionTemp);
}
const fireIcon = new Leaflet.Icon({
- iconUrl: "/fire-marker.png",
+ iconUrl: '/fire-marker.png',
/* shadowUrl: require('../public/marker-shadow.png'), */
- iconSize: [16, 24], // size of the icon
+ iconSize: [16, 24], // size of the icon
/* shadowSize: [50, 64], // size of the shadow */
- iconAnchor: [8, 26] // point of the icon which will correspond to marker's location
+ iconAnchor: [8, 26] // point of the icon which will correspond to marker's location
/* shadowAnchor: [4, 62], // the same for the shadow
- * popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor*/
+ * popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor */
});
const nFireIcon = new Leaflet.Icon({
- iconUrl: "/n-fire-marker.png",
+ iconUrl: '/n-fire-marker.png',
/* shadowUrl: require('../public/marker-shadow.png'), */
- iconSize: [16, 24], // size of the icon
+ iconSize: [16, 24], // size of the icon
/* shadowSize: [50, 64], // size of the shadow */
- iconAnchor: [8, 26] // point of the icon which will correspond to marker's location
+ iconAnchor: [8, 26] // point of the icon which will correspond to marker's location
/* shadowAnchor: [4, 62], // the same for the shadow
- * popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor*/
+ * popupAnchor: [-3, -76]// point from which the popup should open relative to the iconAnchor */
});
// http://leafletjs.com/reference-1.2.0.html#icon
-const MyPopupMarker = ({ children, lat, lon, nasa}) => (
-
- {this.props.activefires.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.:En rojo, {{count: this.props.activefires.length}} fuegos activos en el mapa. Hay un total de {{countTotal: this.props.activefirestotal}} fuegos activos detectados en todo el mundo por la NASA.
+ { this.props.activefires.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. :
+ En rojo, {{ count: this.props.activefires.length }} fuegos activos en el mapa. Hay un total de {{ countTotal: this.props.activefirestotal }} fuegos activos detectados en todo el mundo por la NASA.
}
En naranja, los fuegos notificados por nuestros usuarios/as recientemente.
-
+
this.showSubsUnion(e.target.checked)}>
Resaltar en verde el área vigilada por nuestros usuarios/as (*)
- {(this.state.viewport.zoom >= MAXZOOM) && this.useMarkers(e.target.checked)}>
+ {(this.state.viewport.zoom >= MAXZOOM) &&
+ this.useMarkers(e.target.checked)}>
Resaltar los fuegos con un marcador
- }
- this.centerOnUserLocation(viewport)} />
+ }
+ this.centerOnUserLocation(viewport)} />
{/* https://github.com/CliffCloud/Leaflet.Sleep */}
-
-
(*)Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.
+
(*)Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.
);
- };
-};
-
-const zoom = new ReactiveVar(8);
-const lat = new ReactiveVar(DEF_LAT);
-const lng = new ReactiveVar(DEF_LNG);
-const height = new ReactiveVar(400);
-const width = new ReactiveVar(400);
+ }
+}
FiresMap.propTypes = {
loading: PropTypes.bool.isRequired,
subsready: PropTypes.bool.isRequired,
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
+ firealerts: PropTypes.arrayOf(PropTypes.object).isRequired,
activefirestotal: PropTypes.number.isRequired,
- viewport: PropTypes.object.isRequired
+ viewport: PropTypes.object.isRequired,
+ t: PropTypes.func.isRequired
};
-Meteor.call("geo", function (error, response) {
- if (error) {
- console.warn(error);
- } else {
- lat.set(response.location.latitude);
- lng.set(response.location.longitude);
- }
-});
-
-export default translate([], { wait: true }) (withTracker(() => {
- var subscription;
- Meteor.autorun(function() {
+export default translate([], { wait: true })(withTracker(() => {
+ let subscription;
+ Meteor.autorun(() => {
// Subscribe for the current templateId (only if one is selected). Note this
// will automatically clean up any previously subscribed data and it will
// also stop all subscriptions when this template is destroyed.
+ if (geolocation.get()) {
+ lat.set(geolocation.get()[0]);
+ lng.set(geolocation.get()[1]);
+ }
if (zoom.get() || lat.get() || lng.get()) {
subscription = Meteor.subscribe('activefiresmyloc', zoom.get(), lat.get(), lng.get(), height.get(), width.get());
}
@@ -343,7 +363,7 @@ export default translate([], { wait: true }) (withTracker(() => {
Meteor.subscribe('activefirestotal');
// Right now to all neighborhood alerts
Meteor.subscribe('fireAlerts');
- var userSubs = Meteor.subscribe('userSubsToFires');
+ const userSubs = Meteor.subscribe('userSubsToFires');
// const subscription = Meteor.subscribe('activefiresmyloc', zoom.get());
// console.log(`Active fires ${ActiveFiresCollection.find().fetch().length} of ${Counter.get('countActiveFires')}`);
// console.log(`Active neighborhood fires ${FireAlertsCollection.find().fetch().length} and users subscribed ${UserSubsToFiresCollection.find().fetch().length}`);
@@ -353,11 +373,12 @@ export default translate([], { wait: true }) (withTracker(() => {
subsready: userSubs.ready(),
activefires: ActiveFiresCollection.find().fetch(),
activefirestotal: Counter.get('countActiveFires'),
- firealerts: FireAlertsCollection.find().fetch().map(
- doc => ( { _id: doc['_id'], lat: doc['location'].lat, lon: doc['location'].lon })),
+ firealerts: FireAlertsCollection.find().fetch().map(doc => (
+ { _id: doc._id, lat: doc.location.lat, lon: doc.location.lon }
+ )),
userSubs: UserSubsToFiresCollection.find().fetch(),
viewport: {
- center: [lat.get(), lng.get()], // a point in the sea
+ center: geolocation.get(),
zoom: zoom.get()
}
};