Skip to content

Commit

Permalink
Merge pull request #87 from mbilker/null-record-stash
Browse files Browse the repository at this point in the history
Store records with null coordinates in separate array
  • Loading branch information
vonbearshark authored Jan 28, 2017
2 parents f4147c8 + 2095810 commit d993cab
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

//Array of markers
var markers = new Array();
var nullRecords = new Array();

//Create a new Date object for the current date
var currentDate = new Date();
Expand Down Expand Up @@ -235,20 +236,22 @@
dataSource.processRecord(record, i);
}

const recordLatLong = dataSource.latLong.map((fieldName) => record[fieldName]);
const latLongNoNulls = recordLatLong.some((field) => !!field);
const latLong = latLongNoNulls ? recordLatLong : cathyLatLong;

const title = dataSource.title(record);
record.pin = L.marker(latLong, {
title: title,
icon: dataSource.icon
});

record.pin.bindPopup(dataSource.popup(record));

record.pin.addTo(map)
markers.push(record);
const latLong = dataSource.latLong.map((fieldName) => record[fieldName]);
const latLongNoNulls = latLong.some((field) => !!field);
if (latLongNoNulls) {
const title = dataSource.title(record);
record.pin = L.marker(latLong, {
title: title,
icon: dataSource.icon
});

record.pin.bindPopup(dataSource.popup(record));

record.pin.addTo(map);
markers.push(record);
} else {
nullRecords.push(record);
}
})
});
}
Expand Down

0 comments on commit d993cab

Please sign in to comment.