aboutsummaryrefslogtreecommitdiff
path: root/web/public/javascripts
diff options
context:
space:
mode:
authorKumar Damani <damani.kumar@gmail.com>2019-04-23 01:35:03 +0000
committerKumar Damani <damani.kumar@gmail.com>2019-04-23 01:35:03 +0000
commitbc55c117d22ee4c59d983a0d0cad283f567c4d92 (patch)
tree98d84f48de10aaafe89d8c9afcb3285bea590367 /web/public/javascripts
parent2ed2b0d01b9207b6c5003fe083238720a8409962 (diff)
parentf5d81a36b4869ad0f91aa97451cbbc26004889d6 (diff)
Merge branch 'web-homepage' into 'master'
Web homepage See merge request kdam0/helpthehomeless!1
Diffstat (limited to 'web/public/javascripts')
-rw-r--r--web/public/javascripts/map.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/web/public/javascripts/map.js b/web/public/javascripts/map.js
index 5326bb2..1f18e09 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,11 +164,12 @@ 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';
}
+ map.fitBounds(latlngbounds.pad(0.20));
}
// returns a Promise object
@@ -200,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');