From 2095810af90da8221c430ee9c586da1735675c75 Mon Sep 17 00:00:00 2001 From: mbilker Date: Fri, 27 Jan 2017 16:47:50 -0500 Subject: [PATCH] Store records with null coordinates in separate array --- main.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/main.js b/main.js index f1f98f0..07c4e45 100644 --- a/main.js +++ b/main.js @@ -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(); @@ -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); + } }) }); }