/** * Generate the content element */ protected function compile() { global $objPage; // Contao framework sets images to max-width 100%, which collides with Google's CSS if (!$this->dlh_googlemap_nocss) { \delahaye\googlemaps\Googlemap::CssInjection(); } // get the map data $arrParams = array('mapSize' => deserialize($this->dlh_googlemap_size), 'zoom' => $this->dlh_googlemap_zoom); $arrParams['mapSize'][2] = $arrParams['mapSize'][2] == 'pcnt' ? '%' : $arrParams['mapSize'][2]; $arrMap = \delahaye\googlemaps\Googlemap::getMapData($this->dlh_googlemap, $objPage->outputFormat, $arrParams); // static map if ($this->dlh_googlemap_static) { $this->Template = new \FrontendTemplate('ce_dlh_googlemapsstatic'); if ($this->dlh_googlemap_url) { $arrMap['staticMap'] = '<a href="' . $this->dlh_googlemap_url . '"' . ($this->rel ? ($objPage->outputFormat == 'html5' ? ' data-lightbox="' : ' rel="') . $this->rel . '"' : '') . ' title="' . addslashes($this->linkTitle) . '"' . ($this->target ? ' onclick="window.open(this.href); return false;"' : '') . '>' . $arrMap['staticMap'] . '</a>'; } } else { if ($this->dlh_googlemap_template && $this->dlh_googlemap_template != 'ce_dlh_googlemaps_default') { $this->Template = new \FrontendTemplate($this->dlh_googlemap_template); } $GLOBALS['TL_JAVASCRIPT'][] = 'http' . (\Environment::get('ssl') ? 's' : '') . '://maps.google.com/maps/api/js?language=' . $arrMap['language'] . '&sensor=' . ($arrMap['sensor'] ? 'true' : 'false'); } $this->Template->map = $arrMap; $this->Template->tabs = $this->dlh_googlemap_tabs; $this->Template->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels']; }
/** * Generate the content element */ protected function compile() { global $objPage; $objRootPage = \Database::getInstance()->prepare("select dlh_googlemaps_apikey from tl_page where id=?")->limit(1)->execute($objPage->rootId); // Contao framework sets images to max-width 100%, which collides with Google's CSS if (!$this->dlh_googlemap_nocss) { \delahaye\googlemaps\Googlemap::CssInjection(); } // get the map data $arrParams = array('mapSize' => deserialize($this->dlh_googlemap_size), 'zoom' => $this->dlh_googlemap_zoom); $arrParams['mapSize'][2] = $arrParams['mapSize'][2] == 'pcnt' ? '%' : $arrParams['mapSize'][2]; $arrMap = \delahaye\googlemaps\Googlemap::getMapData($this->dlh_googlemap, $objPage->outputFormat, $arrParams); // static map if ($this->dlh_googlemap_static) { $this->Template = new \FrontendTemplate('ce_dlh_googlemapsstatic'); if ($this->dlh_googlemap_url) { $arrMap['staticMap'] = '<a href="' . $this->dlh_googlemap_url . '"' . ($this->rel ? ($objPage->outputFormat == 'html5' ? ' data-lightbox="' : ' rel="') . $this->rel . '"' : '') . ' title="' . addslashes($this->linkTitle) . '"' . ($this->target ? ' onclick="window.open(this.href); return false;"' : '') . '>' . $arrMap['staticMap'] . '</a>'; } } else { if ($this->dlh_googlemap_template && $this->dlh_googlemap_template != 'ce_dlh_googlemaps_default') { $this->Template = new \FrontendTemplate($this->dlh_googlemap_template); } $GLOBALS['TL_JAVASCRIPT'][] = 'http' . (\Environment::get('ssl') ? 's' : '') . '://maps.google.com/maps/api/js?key=' . $objRootPage->dlh_googlemaps_apikey . '&language=' . $arrMap['language']; if ($arrMap['useClusterer']) { $GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/dlh_googlemaps/assets/js-marker-clusterer-gh-pages/src/markerclusterer.js'; $arrMap['clusterImg'] = $arrMap['clusterImg'] ? $arrMap['clusterImg'] : 'system/modules/dlh_googlemaps/assets/js-marker-clusterer-gh-pages/images'; } } $this->Template->map = $arrMap; $this->Template->tabs = $this->dlh_googlemap_tabs; $this->Template->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels']; }