Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store records with null coordinates in separate array #87

Merged
merged 1 commit into from
Jan 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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