Browse Source

added icons for dead battery scooters (no battery) and damaged/maintenance ones

master
user 4 years ago
parent
commit
85a085d65e
  1. 41
      website/map/index.php

41
website/map/index.php

@ -12,7 +12,7 @@ $scooters = array(
array('https://platform.tier-services.io/v1/vehicle/00020bdd-ee4c-486a-90f5-dd04672cfc54', 'Martin Howse', 'wok_the_cables', 'Adventure game for psychogeophysical divination of portals, realtime instructions to follow #wokthecables'), array('https://platform.tier-services.io/v1/vehicle/00020bdd-ee4c-486a-90f5-dd04672cfc54', 'Martin Howse', 'wok_the_cables', 'Adventure game for psychogeophysical divination of portals, realtime instructions to follow #wokthecables'),
array('https://platform.tier-services.io/v1/vehicle/acd0c627-5b16-461e-a662-65cef778d94d', 'Sofya Aleynikova', 'followers', 'Eine weibliche Protagonistin manifestiert sich als Meme im Web und stellt die richtigen Fragen.'), array('https://platform.tier-services.io/v1/vehicle/acd0c627-5b16-461e-a662-65cef778d94d', 'Sofya Aleynikova', 'followers', 'Eine weibliche Protagonistin manifestiert sich als Meme im Web und stellt die richtigen Fragen.'),
array('https://platform.tier-services.io/v1/vehicle/7eebb2e6-2694-43a2-b390-d8fc70124377', 'JODI', '#4b38$R0ut.IDx', '██████████████████████████████████████████████████▒▒'), array('https://platform.tier-services.io/v1/vehicle/7eebb2e6-2694-43a2-b390-d8fc70124377', 'JODI', '#4b38$R0ut.IDx', '██████████████████████████████████████████████████▒▒'),
array('https://platform.tier-services.io/v1/vehicle/50e749fc-1ebb-41b0-9de7-952db5c0aa05', 'Rosa Menkman', 'Ariane', 'Ariane is a famous Shutterstock model. She also worries about getting older.'), array('https://platform.tier-services.io/v1/vehicle/50e749fc-1ebb-41b0-9de7-952db5c0aa05', 'Rosa Menkmann', 'Ariane', 'Ariane is a famous Shutterstock model. She also worries about getting older.'),
array('https://platform.tier-services.io/v1/vehicle/30895827-25f1-4c07-8528-25c215e80336', 'Sarah Grant', 'Plague Rave 2020', 'Take a katamari style tour with corona through the vibrant Berlin club scene. Download a souvenir photo at the end of the trip!'), array('https://platform.tier-services.io/v1/vehicle/30895827-25f1-4c07-8528-25c215e80336', 'Sarah Grant', 'Plague Rave 2020', 'Take a katamari style tour with corona through the vibrant Berlin club scene. Download a souvenir photo at the end of the trip!'),
array('https://platform.tier-services.io/v1/vehicle/2de46e02-d816-47eb-9ad8-0ecb4178af25', 'Danja Vasiliev', 'need4speed', 'A situationist game in public space adapted for the micro-mobility sector. Rent a scooter, ride while making continuous and sharp turns and find l00t!'), array('https://platform.tier-services.io/v1/vehicle/2de46e02-d816-47eb-9ad8-0ecb4178af25', 'Danja Vasiliev', 'need4speed', 'A situationist game in public space adapted for the micro-mobility sector. Rent a scooter, ride while making continuous and sharp turns and find l00t!'),
array('https://platform.tier-services.io/v1/vehicle/f42debc7-2dd3-4b64-9956-de96a12d2af9', 'Constant Dullaart', 'constant time', 'Your network, your home, as temporary as seconds on the clock. Reconnect.'), array('https://platform.tier-services.io/v1/vehicle/f42debc7-2dd3-4b64-9956-de96a12d2af9', 'Constant Dullaart', 'constant time', 'Your network, your home, as temporary as seconds on the clock. Reconnect.'),
@ -36,7 +36,8 @@ global $scooters; //"import" the global variable into the function's scope
$pos = $lat.', '.$lng; // construct lat/lon for use in leafet $pos = $lat.', '.$lng; // construct lat/lon for use in leafet
$lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position $lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position
$rnt = $arr["data"]["attributes"]["isRentable"]; // check if scooter is rentable, $rnt = $arr["data"]["attributes"]["isRentable"]; // check if scooter is rentable,
$act = $arr["data"]["attributes"]["state"]; // check if scooter is ACTIVE or MAINTAINANCE $act = $arr["data"]["attributes"]["state"]; // check if scooter is: ACTIVE, INACTIVE, MAINTAINANCE, DAMAGED
$bat = $arr["data"]["attributes"]["batteryLevel"]; // battery level 0-100
// access values from the multidimensional $scooters array // access values from the multidimensional $scooters array
$nam = $scooters[$id][1]; // get the artist name $nam = $scooters[$id][1]; // get the artist name
$tit = $scooters[$id][2]; // get the works title $tit = $scooters[$id][2]; // get the works title
@ -67,7 +68,8 @@ function makeMarker(int $id){ // generate appropriate markers based on latest JS
$pos = $arr[$id]["lastPos"]; // get last known position $pos = $arr[$id]["lastPos"]; // get last known position
$lst = $arr[$id]["lastLocationUpdate"]; // get time of last position $lst = $arr[$id]["lastLocationUpdate"]; // get time of last position
$rnt = $arr[$id]["isRentable"]; // check if scooter is rentable, $rnt = $arr[$id]["isRentable"]; // check if scooter is rentable,
$act = $arr[$id]["state"]; // check if scooter is ACTIVE or MAINTAINANCE $act = $arr[$id]["state"]; // check if scooter is: ACTIVE, INACTIVE, MAINTAINANCE, DAMAGED
$bat = $arr[$id]["batteryLevel"]; // battery level 0-100
// access values from the multidimensional $scooters array // access values from the multidimensional $scooters array
$nam = $arr[$id]["name"]; // get the artist name $nam = $arr[$id]["name"]; // get the artist name
$tit = $arr[$id]["title"]; // get the works title $tit = $arr[$id]["title"]; // get the works title
@ -80,22 +82,39 @@ function makeMarker(int $id){ // generate appropriate markers based on latest JS
//check if scooter is rentable //check if scooter is rentable
if($rnt == true && $act === 'ACTIVE'){ if($rnt == true && $act === 'ACTIVE'){
$marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map) $marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map)
.bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: rentable, gallery online") .bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: rentable, gallery available")
.bindTooltip("'.$nam.'").setIcon(availableIcon);'; .bindTooltip("'.$nam.'").setIcon(availableIcon);';
} elseif ($rnt == false && $act === 'ACTIVE') { //check if scooter is rented out
};
if ($rnt == false && $act === 'ACTIVE') {
$marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map) $marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map)
.bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: rented out, gallery on the move") .bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: rented out, gallery on the move")
.bindTooltip("'.$nam.'").setIcon(isRentedIcon);'; .bindTooltip("'.$nam.'").setIcon(isRentedIcon);';
}; };
//check if scooter is in maintenace //check if scooter battery is low
if($act !== "ACTIVE"){ if($act === "INACTIVE" && $bat > 0){
$marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map) $marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map)
.bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: battery low, gallery online") .bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: battery low, gallery online")
.bindTooltip("'.$nam.'").setIcon(lowBatIcon);';
};
//check if scooters battery is dead
if($act === "INACTIVE" && $bat == 0){
$marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map)
.bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: battery dead, gallery unavailable")
.bindTooltip("'.$nam.'").setIcon(noBatIcon);';
};
//check if scooters is dead
if($act === "DAMAGED" || $act === "MAINTAINANCE"){
$marker = 'var scooter'.$id.' = L.marker(['.$pos.'], {time: "'.$lst.'"}).addTo(map)
.bindPopup("<b>'.$tit.'</b><br>'.$des.'<br>Last updated: '.$lst=str_replace(array('T', 'Z'), ' ', $lst).'<br>Status: scooter in maintenance, gallery unavailable")
.bindTooltip("'.$nam.'").setIcon(isMaintenanceIcon);'; .bindTooltip("'.$nam.'").setIcon(isMaintenanceIcon);';
}; };
return $marker; return $marker;
@ -420,9 +439,15 @@ function callAPI($url){
var isRentedIcon = L.AwesomeMarkers.icon( var isRentedIcon = L.AwesomeMarkers.icon(
{"icon": "hourglass-half", "iconColor": "white", "spin": "true", "markerColor": "pink", "prefix": "fa"} {"icon": "hourglass-half", "iconColor": "white", "spin": "true", "markerColor": "pink", "prefix": "fa"}
); );
var isMaintenanceIcon = L.AwesomeMarkers.icon( var lowBatIcon = L.AwesomeMarkers.icon(
{"icon": "battery-1", "iconColor": "white", "markerColor": "pink", "prefix": "fa"} {"icon": "battery-1", "iconColor": "white", "markerColor": "pink", "prefix": "fa"}
); );
var noBatIcon = L.AwesomeMarkers.icon(
{"icon": "battery-empty", "iconColor": "white", "markerColor": "black", "prefix": "fa"}
);
var isMaintenanceIcon = L.AwesomeMarkers.icon(
{"icon": "wrench", "iconColor": "white", "markerColor": "black", "prefix": "fa"}
);
var map = L.map('map', { zoomControl: false, attributionControl: false }).setView([52.516190, 13.377693], 11.5); var map = L.map('map', { zoomControl: false, attributionControl: false }).setView([52.516190, 13.377693], 11.5);

Loading…
Cancel
Save