diff --git a/transport/TEC/Map/GetLineCoordinates.php b/transport/TEC/Map/GetLineCoordinates.php old mode 100644 new mode 100755 index 6a45836..26bdddb --- a/transport/TEC/Map/GetLineCoordinates.php +++ b/transport/TEC/Map/GetLineCoordinates.php @@ -1,28 +1,32 @@ <?php require_once('includes/cache/cache.php'); function get_stops ($line, $date = null, $bypassCache = false) { //Gets current date if needed if ($date === null) $date = today(); //Loads cache information $cache = Cache::load(); $key = "tools-ds-TEC-$line-$date"; if (!$bypassCache && $data = $cache->get($key)) { return unserialize($data); } //JSON query $url = "http://www.infotec.be/hastinfo/published/Horaire.axd?date=$date&ligne=$line"; $data = file_get_contents($url); $json = json_decode($data); $stops = $json->items[0]->horaire->stops; $cache->set($key, serialize($stops)); return $stops; } -$stops = get_stops($_REQUEST['line']); +if (!$_REQUEST['line']) { + die('null'); +} +$date = array_key_exists('date', $_REQUEST) ? $_REQUEST['date'] : null; +$stops = get_stops($_REQUEST['line'], $date); echo json_encode($stops); diff --git a/transport/TEC/Map/LineMap.js b/transport/TEC/Map/LineMap.js index c110a06..e6a4b3d 100644 --- a/transport/TEC/Map/LineMap.js +++ b/transport/TEC/Map/LineMap.js @@ -1,47 +1,46 @@ // Graphics data var stopIcon = L.icon({ iconUrl: '/images/commons/City%20locator%2015.svg-28px.png', }); function DrawMap (line, infoLayerGroup) { // Map centered to Charleroi var map = L.map('map').setView([50.411143, 4.447746], 12); // OSM and Google Maps tiles var OpenStreetMap = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' }); var GoogleMapsRoadmap = new L.Google('ROADMAP'); var GoogleMapsSat = new L.Google('SATELLITE'); var GoogleMapsHybrid = new L.Google('HYBRID'); - map.addLayer(GoogleMapsHybrid); +// map.addLayer(GoogleMapsHybrid); + map.addLayer(OpenStreetMap); map.addLayer(infoLayerGroup); } // Gets line data function DrawLine (line) { require(["dojo/request/xhr"], function(xhr){ xhr("GetLineCoordinates.php?line=" + line, { handleAs: "json" }).then(function (data) { // Processes data var markersStop = new L.LayerGroup(); for (var i = 0 ; i < data.length ; i++) { //Each stop is an object with the following properties: id desc lng lat var stop = data[i]; markersStop.addLayer(L.marker([stop.lat, stop.lng], {icon: stopIcon}) .bindPopup(stop.desc) .openPopup()); } DrawMap(line, markersStop); }, function (err) { // TODO: handles error }, function (evt) { // TODO: handles progress event (XHR2) }); }); -} - -DrawLine('C75'); +} \ No newline at end of file diff --git a/transport/TEC/Map/index.php b/transport/TEC/Map/index.php old mode 100644 new mode 100755 index 3e88448..d86f1bf --- a/transport/TEC/Map/index.php +++ b/transport/TEC/Map/index.php @@ -1,13 +1,16 @@ <div id="map" style="height: 600px; margin-bottom: 0.25em;"> </div> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.css" /> <!--[if lte IE 8]> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.ie.css" /> <![endif]--> <script src="http://cdn.leafletjs.com/leaflet-0.6.2/leaflet.js"></script> <script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js"></script> <script src="//maps.google.com/maps/api/js?v=3.2&sensor=false"></script> <script src="/javascripts/leaflet.google.js"></script> <script src="LineMap.js"></script> +<script> + DrawLine('<?= $_REQUEST['Line'] ? $_REQUEST['Line'] : 'C75' ?>'); +</script> diff --git a/transport/TEC/index.php b/transport/TEC/index.php old mode 100644 new mode 100755 diff --git a/transport/index.php b/transport/index.php old mode 100644 new mode 100755