/** * Renders HTML from template * * @param array $customVariables */ private function renderHTML($customVariables = array()) { $twig = new \Twig_Environment(new \Twig_Loader_Filesystem(self::TEMPLATES_DIRECTORY)); $customPageTitle = $this->config->getMapPageTitle(); $pageTitle = array('GeoPal'); if (!empty($customPageTitle)) { array_unshift($pageTitle, $customPageTitle); } $this->mapPageHTML = $twig->loadTemplate(self::MAP_PAGE_TEMPLATE)->render($customVariables + array('googleMapsAPIKey' => $this->config->getGoogleMapsAPIKey(), 'pageTitle' => implode(' - ', $pageTitle))); }
<?php // Path to config file (relative or absolute) const CONFIG_FILE = './config.php'; ///// DO NOT EDIT BELOW ///// // Init auto-loader require_once implode(DIRECTORY_SEPARATOR, array(__DIR__, 'vendor', 'autoload.php')); // Set class references use GeoPal\Map\Config; use GeoPal\Map\Tracker; // Store and clean up action request alias param (if present) $action = isset($_GET['action']) ? preg_replace('/[\\W]*/', null, $_GET['action']) : null; // Create Map Tracker instance $tracker = Tracker::create(Config::create(CONFIG_FILE)); // Process request if (empty($action)) { $tracker->renderMap()->dumpHTML(); } else { $tracker->getData($action); }
/** * Returns the configured default center lat, lng and zoom * * @return array */ private function getCenterLatLng() { $latLng = explode(',', $this->config->getDefaultMapCenter()); $response = array('latitude' => (double) trim($latLng[0]), 'longitude' => (double) trim($latLng[1]), 'zoom' => (int) $this->config->getDefaultMapZoom(), 'success' => true); return $response; }