Enable opasity variation with time on location records

revert-dabc3590
kamidu 8 years ago
parent 60046823dd
commit eb9c789b51

@ -31,9 +31,11 @@ function loadLeafletMap() {
map = L.map(container).setView([locationSets[0].lat, locationSets[0].lng], zoomLevel); map = L.map(container).setView([locationSets[0].lat, locationSets[0].lng], zoomLevel);
L.tileLayer(tileSet, {attribution: attribution}).addTo(map); L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
var initTime = locations.times[0].time, lastTime = locations.times[locationSets.length - 1].time;
var totalTime = lastTime - initTime;
for (var i = 0; i < locationSets.length; i++) { for (var i = 0; i < locationSets.length; i++) {
console.log(locationSets[i]); var opacVal = (locations.times[i].time - initTime) / totalTime;
var m = L.marker(locationSets[i]).addTo(map).bindPopup(new Date(locations.times[i].time).toISOString()) var m = L.marker(locationSets[i], {"opacity": opacVal}).addTo(map).bindPopup(new Date(locations.times[i].time).toISOString());
m.on('mouseover', function (e) { m.on('mouseover', function (e) {
this.openPopup(); this.openPopup();
}); });

@ -33,9 +33,11 @@ function loadLeafletMap() {
var locationSets = locations.locations; var locationSets = locations.locations;
map = L.map(container).setView([lat, long], zoomLevel); map = L.map(container).setView([lat, long], zoomLevel);
L.tileLayer(tileSet, {attribution: attribution}).addTo(map); L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
var initTime = locations.times[0].time, lastTime = locations.times[locationSets.length - 1].time;
var totalTime = lastTime - initTime;
for (var i = 0; i < locationSets.length; i++) { for (var i = 0; i < locationSets.length; i++) {
var m = L.marker(locationSets[i]).addTo(map).bindPopup(new Date(locations.times[i].time).toISOString()) var opacVal = (locations.times[i].time - initTime) / totalTime;
var m = L.marker(locationSets[i], {"opacity": opacVal}).addTo(map).bindPopup(new Date(locations.times[i].time).toISOString());
m.on('mouseover', function (e) { m.on('mouseover', function (e) {
this.openPopup(); this.openPopup();
}); });

Loading…
Cancel
Save