exit(json_encode(array('stops' => $stops))); } */ if (isset($_GET['route'])) { $routeId = $_GET['route']; $route = $db->routes->findOne(array('_id' => new MongoId($routeId))); $view->assign('stops', $route['stops']); if ($route) { $stops = $route['stops']; $markers = array(); $markerUrl = ""; $mapPath = array('color:0xff0000ff', 'weight:4'); // Fill the rest with coord path $i = 0; foreach ($stops as $st) { $stop = BusStops::getStop($st['name']); $i++; if ($stop !== null && isset($stop['location']) && $i % 4) { $m = $stop['location'][0] . "," . $stop['location'][1]; $markers[] = $m; $markerUrl .= "&markers=size:mid|color:red|label:{$i}|{$m}"; } } $mapPath = array_merge($mapPath, $markers); $mapUrl = "http://maps.google.com/maps/api/staticmap?path=" . implode('|', $mapPath); $mapUrl .= "&size=512x512&sensor=false" . $markerUrl; $view->assign('mapUrl', $mapUrl); $view->assign('stops', $route['stops']); // Fetch all departures for this route $tplDepartures = $routeSearch->getRouteDepartures($route['_id']); foreach ($tplDepartures as $day => $deps) {
require_once "../Config.php"; require_once "../libs/BusStops.php"; $db = Config::getDb(); $view = Config::getView(); $stops = BusStops::getStopList(true, true); $stopList = array(); while ($s = $stops->getNext()) { $id = (string) $s['_id']; $stopList[$id] = array('id' => $id, 'name' => $s['name']); } $view->assign("stops", $stopList); if (isset($_GET['stop']) && !empty($_GET['stop'])) { $stopId = $_GET['stop']; $stop = BusStops::byId($stopId); if ($stop) { if (isset($_GET['update']) && isset($_GET['lat']) && isset($_GET['lng'])) { $lat = (double) $_GET['lat']; $lng = (double) $_GET['lng']; if (BusStops::updatePos($stop, $lat, $lng)) { exit(json_encode(array("ok" => true))); } else { exit(json_encode(array("ok" => false))); } } list($lat, $long) = $stop['location']; $view->assign("lat", $lat); $view->assign("long", $long); $view->assign("stop", $stop); } } $view->display('map.tpl');