From 14f3642f1ea4d32c17d56ffebf5cfd14fb5f5f2c Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 18 Apr 2019 21:20:51 -0400 Subject: web ui updates --- web/public/javascripts/map.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'web/public/javascripts/map.js') diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 5326bb2..3f1f040 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -15,10 +15,11 @@ const Races = { const PendingIcon = new L.Icon({ iconAnchor: [ 12, 41 ], - iconUrl: "../assets/orange-icon.png", + iconUrl: "../images/orange-icon.png", iconSize: [ 25, 41 ], popupAnchor: [ 1, -34 ], shadowSize: [ 41, 41 ], + shadowUrl: "../images/marker-shadow.png", tooltipAnchor: [ 16, -28 ] }); @@ -44,22 +45,22 @@ function plotPointsOnMap(points) { function showDetails(e) { if(currPoint !== undefined) { if (currPoint.feature.geometry.status === "new") { - currPoint._icon.src = '../assets/blue-icon.png'; + currPoint._icon.src = '../images/blue-icon.png'; } else if (currPoint.feature.geometry.status === "pending") { - currPoint._icon.src = '../assets/orange-icon.png'; + currPoint._icon.src = '../images/orange-icon.png'; } } // layer.feature.geometry gives you access to all the fields let layer = e.layer; currPoint = layer; - + if (currPoint.feature.geometry.status === "new") { - currPoint._icon.src = '../assets/blue-icon-focused.png'; + currPoint._icon.src = '../images/blue-icon-focused.png'; } else if (currPoint.feature.geometry.status === "pending") { - currPoint._icon.src = '../assets/orange-icon-focused.png'; + currPoint._icon.src = '../images/orange-icon-focused.png'; } const pointBounds = [currPoint.getLatLng()]; @@ -128,13 +129,13 @@ function markAsPending(e) { let currPointId = currPointDetails._id; if (currPointDetails.status === "pending") return; - currPoint._icon.src = '../assets/orange-icon-focused.png'; + currPoint._icon.src = '../images/orange-icon-focused.png'; currPointDetails.status = "pending"; updatePointStatusInDb(currPointId, "pending") .then(function(responseJson) { alert("Your change has been saved."); - currPoint._icon.src = '../assets/orange-icon-focused.png'; + currPoint._icon.src = '../images/orange-icon-focused.png'; }) .catch(function(error) { alert(error); @@ -163,10 +164,10 @@ function closeDetails(e) { details.style.visibility = 'hidden'; if (currPoint.feature.geometry.status === "pending") { - currPoint._icon.src = '../assets/orange-icon.png'; + currPoint._icon.src = '../images/orange-icon.png'; } else if (currPoint.feature.geometry.status === "new") { - currPoint._icon.src = '../assets/blue-icon.png'; + currPoint._icon.src = '../images/blue-icon.png'; } } -- cgit v1.2.3 From 8f0e47f48bd732eee3a825dd6626fd3a759b1985 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Thu, 18 Apr 2019 22:04:44 -0400 Subject: bug fix for initial load without any points --- web/public/javascripts/map.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'web/public/javascripts/map.js') diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js index 3f1f040..1f18e09 100644 --- a/web/public/javascripts/map.js +++ b/web/public/javascripts/map.js @@ -169,6 +169,7 @@ function closeDetails(e) { else if (currPoint.feature.geometry.status === "new") { currPoint._icon.src = '../images/blue-icon.png'; } + map.fitBounds(latlngbounds.pad(0.20)); } // returns a Promise object @@ -201,7 +202,10 @@ L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r} // map to fit them all var latlngbounds = new L.latLngBounds(); -plotPointsOnMap(points); +if (points.length) { + plotPointsOnMap(points); +} +// setup live updates if (window.EventSource) { var source = new EventSource('/stream'); -- cgit v1.2.3