|
|
|
@ -20,19 +20,17 @@ var map;
|
|
|
|
|
|
|
|
|
|
function loadLeafletMap() {
|
|
|
|
|
var deviceLocationID = "#device-location",
|
|
|
|
|
lat = $(deviceLocationID).data("lat"),
|
|
|
|
|
long = $(deviceLocationID).data("long"),
|
|
|
|
|
locations = $(deviceLocationID).data("locations"),
|
|
|
|
|
container = "device-location",
|
|
|
|
|
zoomLevel = 13,
|
|
|
|
|
tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
|
|
|
attribution = "© <a href='https://openstreetmap.org/copyright'>OpenStreetMap</a> contributors";
|
|
|
|
|
|
|
|
|
|
if (locations) {
|
|
|
|
|
|
|
|
|
|
var locationSets = locations.locations;
|
|
|
|
|
map = L.map(container).setView([lat, long], zoomLevel);
|
|
|
|
|
map = L.map(container).setView([locationSets[0].lat, locationSets[0].lng], zoomLevel);
|
|
|
|
|
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++) {
|
|
|
|
@ -55,14 +53,7 @@ function loadLeafletMap() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
|
$("a[data-toggle='tab']").on("shown.bs.tab", function () {
|
|
|
|
|
var url = $(this).prop("href");
|
|
|
|
|
var hash = url.substring(url.indexOf("#") + 1);
|
|
|
|
|
|
|
|
|
|
if (hash == "device_location_tab") {
|
|
|
|
|
if (!map) {
|
|
|
|
|
loadLeafletMap();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$(".location_tab").on("click", function () {
|
|
|
|
|
loadLeafletMap();
|
|
|
|
|
});
|
|
|
|
|
});
|