Пример #1
0
 /**
  * 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'] . '&amp;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'];
 }
Пример #2
0
 /**
  * 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'];
 }
 public function generate(array $arrOptions = array())
 {
     $this->arrOptions = array_merge($this->arrOptions, $arrOptions);
     $arrData = $this->getData($this->arrOptions);
     if (!$arrOptions['dlh_googlemap_nocss']) {
         \delahaye\googlemaps\Googlemap::CssInjection();
     }
     $this->arrOptions['staticMap'] = $this->generateStatic($this->arrOptions);
     $objTemplate = new \FrontendTemplate($this->arrOptions['dlh_googlemap_template']);
     if (!isset($GLOBALS['TL_JAVASCRIPT']['googlemaps'])) {
         $strUrl = '//maps.google.com/maps/api/js';
         $strUrl = Url::addQueryString('language=' . $this->arrOptions['language'], $strUrl);
         global $objPage;
         if (($objRootPage = \PageModel::findPublishedById($objPage->rootId)) !== null && $objRootPage->dlh_googlemaps_apikey) {
             $strUrl = Url::addQueryString('key=' . $objRootPage->dlh_googlemaps_apikey, $strUrl);
         }
         $GLOBALS['TL_JAVASCRIPT']['googlemaps'] = $strUrl;
     }
     $objTemplate->map = $arrData;
     $objTemplate->tabs = $arrData['dlh_googlemap_tabs'];
     $objTemplate->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels'];
     return $objTemplate->parse();
 }