summaryrefslogtreecommitdiff
path: root/car2go-ptv/ptv.js
blob: 3b085239d7c423ab97b60e5386c1d399c0a5cbc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var btnFilter = document.createElement("button");
btnFilter.innerHTML = "Nur < 25% anzeigen";
btnFilter.onclick = function() {
    ptvMap.clearVectorLayer();
    var selectedVehicles = [];

    for (var i in ptvMap.data.vehicles) {
     var v = ptvMap.data.vehicles[i];
     if (typeof(v.tooltip) === "undefined")
       continue;
     var tank = v.tooltip.data[3].value.match(/\d+/)[0];
     if (parseInt(tank) < 25) {
       selectedVehicles.push(v);
     }
    }
    ptvMap.addVehicles(selectedVehicles);
}
document.getElementById("content").appendChild(btnFilter);

var btnUnfilter = document.createElement("button");
btnUnfilter.innerHTML = "Alle Anzeigen";
btnUnfilter.onclick = function() {
    ptvMap.clearVectorLayer();
    ptvMap.addVehicles(ptvMap.data.vehicles);
}
document.getElementById("content").appendChild(btnUnfilter);