diff --git a/assignment/images/marker-icon1.png b/assignment/images/marker-icon1.png new file mode 100644 index 0000000..e2e9f75 Binary files /dev/null and b/assignment/images/marker-icon1.png differ diff --git a/assignment/images/marker-icon2.png b/assignment/images/marker-icon2.png new file mode 100644 index 0000000..97d04dc Binary files /dev/null and b/assignment/images/marker-icon2.png differ diff --git a/assignment/index.html b/assignment/index.html index 33922b5..6605276 100644 --- a/assignment/index.html +++ b/assignment/index.html @@ -62,20 +62,45 @@ ===================== */ - var jsonToCsv = function(json) { console.log(json); }; - var addMarkers = function(map) {}; + var csvHC = []; - /* ===================== + var jsonToCsv = (obj) => { + csvHC.push(Object.keys(obj[0])); + for (i = 0; i < obj.length; i++) { + csvHC.push(Object.values(obj[i])) + } + }; - End code + jsonToCsv(healthCenters); - ===================== */ + console.log(csvHC); + var myIcon1 = L.icon({iconUrl:'images/marker-icon1.png', + shadowUrl:'images/marker-shadow.png'}); + + var myIcon2 = L.icon({iconUrl:'images/marker-icon2.png', + shadowUrl:'images/marker-shadow.png'}); + + + var addMarkers = (obj) => { + for (var i = 1 ; i < obj.length; i++) { + if (obj[i][5]>=19140 && obj[i][5]<=19149) { + if (obj[i][8]!="N/A") { + L.marker([obj[i][1],obj[i][0]],{icon: myIcon1}).addTo(map) + .bindPopup(obj[i][3]) + } else { + L.marker([obj[i][1],obj[i][0]],{icon: myIcon2}).addTo(map) + .bindPopup(obj[i][3]) + } + } + } + } + + + addMarkers(csvHC); - jsonToCsv(healthCenters); - addMarkers(map);
+