Skip to content

Commit a21fee5

Browse files
author
gondzo
committed
changes for issue #13
1 parent c56dfd6 commit a21fee5

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/components/MapHistory/MapHistory.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import styles from './MapHistory.scss';
88

99
const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
1010

11-
const tipFormatter = (v) => moment(v).format(DATE_FORMAT);
11+
const tipFormatter = (v) => moment(v).format(DATE_FORMAT);// eslint-disable-line new-cap
1212

1313
class MapHistory extends React.Component {
1414
constructor(props) {
@@ -44,7 +44,7 @@ class MapHistory extends React.Component {
4444

4545
// a overlay to translate from pixel to latlng and the reverse
4646
this.overlay = new google.maps.OverlayView();
47-
this.overlay.draw = () => {};
47+
this.overlay.draw = _.noop;
4848
this.overlay.setMap(this.map);
4949

5050
// a info window to show location created date
@@ -58,7 +58,7 @@ class MapHistory extends React.Component {
5858
// get map's bounds based on locations
5959
getBounds() {
6060
const bounds = new google.maps.LatLngBounds();
61-
_.each(this.props.locations, (l) => {
61+
_.forEach(this.props.locations, (l) => {
6262
bounds.extend(_.pick(l, 'lat', 'lng'));
6363
});
6464
return bounds;
@@ -86,7 +86,7 @@ class MapHistory extends React.Component {
8686
});
8787

8888
// interpolate start location if not existed
89-
_.each(this.props.locations, (l, i, c) => {
89+
_.forEach(this.props.locations, (l, i, c) => {
9090
const time1 = new Date(l.createdAt).getTime();
9191
if (time1 >= this.dateRange[0]) {
9292
if (time1 > this.dateRange[0]) {
@@ -104,7 +104,7 @@ class MapHistory extends React.Component {
104104
});
105105

106106
// interpolate end location if not existed
107-
_.eachRight(this.props.locations, (l, i, c) => {
107+
_.forEachRight(this.props.locations, (l, i, c) => {
108108
const time1 = new Date(l.createdAt).getTime();
109109
if (time1 <= this.dateRange[1]) {
110110
if (time1 < this.dateRange[1]) {
@@ -128,7 +128,7 @@ class MapHistory extends React.Component {
128128
filterMarkers() {
129129
this.omitMarkers = 0;
130130
let lastMarker;
131-
_.each(this.markers, (m) => {
131+
_.forEach(this.markers, (m) => {
132132
if (!lastMarker) {
133133
lastMarker = m;
134134
m.setVisible(true);
@@ -166,7 +166,7 @@ class MapHistory extends React.Component {
166166

167167
// clear exsiting markers
168168
if (this.markers) {
169-
_.each(this.markers, (m) => {
169+
_.forEach(this.markers, (m) => {
170170
m.setMap(null);
171171
});
172172
}

src/routes/DronesMap/components/DronesMapView.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import MarkerClusterer from 'node-js-marker-clusterer';
44
import MapHistory from 'components/MapHistory';
55
import Info from './Info';
66
import styles from './DronesMapView.scss';
7+
const _ = require('lodash');
78

89
const getIcon = (status) => {
910
switch (status) {
@@ -38,7 +39,7 @@ class DronesMapView extends React.Component {
3839
const {drones, mapSettings, showInfo, hideInfo} = this.props;
3940
this.map = new google.maps.Map(this.node, mapSettings);
4041
const overlay = new google.maps.OverlayView();
41-
overlay.draw = () => {};
42+
overlay.draw = _.noop;
4243
overlay.setMap(this.map);
4344
const hideInfoWindow = () => {
4445
this.props.infoDrone && hideInfo();

src/routes/DronesMap/modules/DronesMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ export const HIDE_HISTORY = 'DronesMap/HIDE_HISTORY';
3535

3636
// load drones and initialize socket
3737
export const init = () => async(dispatch) => {
38-
const {body: {items: drones}} = await APIService.searchDrones({limit: DRONE_LIMIT});
38+
const {body: {items: allDrones}} = await APIService.searchDrones({limit: DRONE_LIMIT});
3939
lastUpdated = new Date().getTime();
40+
const drones = _.filter(allDrones,
41+
(d) => d.currentLocation && d.currentLocation.length > 0);
4042
dispatch({type: DRONES_LOADED, payload: {drones}});
4143
socket = io(config.socket.url);
4244
socket.on('dronepositionupdate', (drone) => {

webpack.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ module.exports = {
9797
},
9898
plugins: [
9999
new Dotenv({
100-
path: '.env', // if not simply .env
101-
safe: true // lets load the .env.example file as well
100+
path: '.env', // if not simply .env
101+
safe: true, // lets load the .env.example file as well
102102
}),
103103
new webpack.DefinePlugin({
104-
__COVERAGE__: !argv.watch && process.env.NODE_ENV === 'test'
104+
__COVERAGE__: !argv.watch && process.env.NODE_ENV === 'test',
105105
}),
106106
new HtmlWebpackPlugin({
107107
GOOGLE_API_KEY: config.GOOGLE_API_KEY,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy