// Below is the static html to generate the map, it can also be done more dynamically using https://github.com/LuminFire/leaflet-php but that might be overkill
// Below is the static html to generate the map, it can also be done more dynamically using https://github.com/LuminFire/leaflet-php but that might be overkill
array('https://opencoil.show/test-json.php?scooterID=2', 'artist name 1', 'title 1', 'desciption 1' ),
'https://opencoil.show/test-json.php?scooterID=2'
array('https://opencoil.show/test-json.php?scooterID=3', 'artist name 2', 'title 2', 'desciption 2' ),
//array('https://platform.tier-services.io/v1/vehicle/fbd739d6-554f-4eaf-bd9c-afe3d501c94b', 'artist name 1', 'title', 'desciption'),
);
);
//make it like this
//$scooters = array(
//'https://opencoil.show/test-json.php?scooterID=1', name of artist, title, desc
//);
// for each scooter in array get the json (TODO, for each, safe to file/database?) $scooters is a multidimensional array: $scooter[0][0] = the first data (api url) of the first scooter, $scooter[1][0] = the first data (api url) of the second scooter, $scooter[0][1] = the artist name of the first scooter etcetc.
$id = 0; //get the first scooter for now
// for each scooter in array get the json (TODO, for each, safe to file/database?)
$getJSON = callAPI($scooters[0]);
// decode JSON data to PHP associative array
$arr = json_decode($getJSON, true);
// access values from the associative array
$lat = $arr["data"]["attributes"]["lat"]; // get lattitude
$lng = $arr["data"]["attributes"]["lng"]; // get longitude
$lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position
$rnt = $arr["data"]["attributes"]["isRentable"]; // check if scooter is rentable,
$act = $arr["data"]["attributes"]["state"]; // check if scooter is ACTIVE or MAINTAINANCE
//check if scooter is rentable
function makeMarker(int $id){
// if($rnt == true){
global $scooters; //"import" the global variable into the function's scope
// echo "rentable";
$getJSON = callAPI($scooters[$id][0]); //abstract callAPI for neater reuse
// } else {
$arr = json_decode($getJSON, true); // decode JSON data to PHP associative array
// echo "gallery not available";
// access values from the associative array
// };
$lat = $arr["data"]["attributes"]["lat"]; // get lattitude
$lng = $arr["data"]["attributes"]["lng"]; // get longitude
$pos = $lat.', '.$lng; // construct lat/lon for use in leafet
$lst = $arr["data"]["attributes"]["lastLocationUpdate"]; // get time of last position
$rnt = $arr["data"]["attributes"]["isRentable"]; // check if scooter is rentable,
$act = $arr["data"]["attributes"]["state"]; // check if scooter is ACTIVE or MAINTAINANCE
// access values from the multidimensional $scooters array
$nam = $scooters[$id][1]; // get the artist name
$tit = $scooters[$id][2]; // get the works title
$des = $scooters[$id][3]; // get the works description
//check if scooter status (if ACTIVE)
//check scooter status and construct marker with corresponding icon
// TODO save json to file?...mmm one big one? seperate ones, timestamped ones?
// TODO save json to file?...mmm one big one? seperate ones, timestamped ones?
// 60 second update interval
// 60 second update interval
@ -70,8 +88,9 @@ $pos = $lat.', '.$lng;
// check if lastlocation is different...if update > latest file (map file..)
// check if lastlocation is different...if update > latest file (map file..)
// check if is rentable
// check if is rentable
// 2 json files: is retantable, latlong, id, status
// TODO make two files
// historical: every 60 sec needs update..even tho no state changes
// 1: current position and state of scooter, latlong, id, status
// 2: historical json file, contains all scooters, updated everytime php file is loaded (or every 60 sec). No state changes, only lat long and time. even if time does not change
@ -150,10 +169,10 @@ function callAPI($url){
// prefix: glyphicon = bootstrap, list can be found here: https://getbootstrap.com/docs/3.3/components/
// prefix: glyphicon = bootstrap, list can be found here: https://getbootstrap.com/docs/3.3/components/
// prefix: fa = fontawesome, list is here: https://fontawesome.com/v4.7.0/cheatsheet/
// prefix: fa = fontawesome, list is here: https://fontawesome.com/v4.7.0/cheatsheet/