Skip to content

Commit

Permalink
Store records with null coordinates in separate array
Browse files Browse the repository at this point in the history
  • Loading branch information
mbilker committed Jan 27, 2017
1 parent 42ce8e9 commit 2095810
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 @@ -210,20 +211,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 2095810

Please sign in to comment.