}
MyMarkersList.propTypes = {
markers: PropTypes.array.isRequired,
}
MyCirclesList.propTypes = {
circles: PropTypes.array.isRequired,
}
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,
}
class FiresMap extends React.Component {
constructor(props) {
super(props);
this.state = {
viewport: DEFAULT_VIEWPORT,
modified: false
}
}
centerOnUserLocation = () => {
// https://atmospherejs.com/mdg/geolocation
// https://stackoverflow.com/questions/31608579/somethings-wrong-with-my-meteor-geolocation-functions
var userGeoLocation = new ReactiveVar(null);
var state = this.state;
Tracker.autorun(function (computation) {
userGeoLocation.set(Geolocation.latLng());
if (userGeoLocation.get()) {
//stop the tracker if we got something
computation.stop();
console.log(userGeoLocation.get());
state.viewport = {
center: [userGeoLocation.get().lat, userGeoLocation.get().lng],
zoom: 11
}
}
});
}
onViewportChanged = viewport => {
// console.log(this.state.viewport);
zoom.set(viewport.zoom);
lat.set(viewport.center[0]);
lng.set(viewport.center[1]);
this.state = { viewport: viewport, modified: true };
}
onClickReset = () => {
// console.log("onclick");
// this.setState({ viewport: DEFAULT_VIEWPORT })
}
render() {
// const position = [this.default.lat, this.default.lng];
// const position = this.props.geoip || [this.default.lat, this.default.lng];
this.state = {
viewport: !this.state.modified && this.props.viewport && Array.isArray(this.props.viewport.center)? this.props.viewport: this.state.viewport,
modified: this.state.modified
}
return (
/* Large number of markers:
https://stackoverflow.com/questions/43015854/large-dataset-of-markers-or-dots-in-leaflet/43019740#43019740 */
{this.props.loading ?
:""}
Fuegos activos
Fuentes: NASA y alertas vecinales de nuestr@s usuari@s
);
}
}
const geoip = new ReactiveVar('');
const zoom = new ReactiveVar(8);
const lat = new ReactiveVar(DEF_LAT);
const lng = new ReactiveVar(DEF_LNG);
FiresMap.propTypes = {
loading: PropTypes.bool.isRequired,
activefires: PropTypes.arrayOf(PropTypes.object).isRequired,
activefirestotal: PropTypes.number.isRequired,
viewport: PropTypes.object.isRequired
};
export default translate([], { wait: true }) (withTracker(() => {
var subscription;
Meteor.autorun(function() {
// 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 (zoom.get())
// TODO select position
subscription = Meteor.subscribe('activefiresmyloc', zoom.get(), lat.get(), lng.get());
});
Meteor.subscribe('activefirestotal');
// const subscription = Meteor.subscribe('activefiresmyloc', zoom.get());
Meteor.call("geo", function (error, response) {
if (error) {
console.warn(error);
} else {
geoip.set([response.location.latitude, response.location.longitude] );
}
});
return {
loading: !subscription.ready(),
activefires: ActiveFiresCollection.find().fetch(),
activefirestotal: Counter.get('countActiveFires'),
viewport: {
center: geoip.get(), // a point in the sea
zoom: zoom.get(),
}
};
})(FiresMap));