/** * Get the map configuration * @param int * @param string * @param array * @return array */ public static function getMapData($intMap, $strFormat = '', $arrParams = false) { // set tag ending $strTagEnding = $strFormat == 'xhtml' ? ' />' : '>'; // get map data $objMap = \delahaye\googlemaps\MapModel::findByPk($intMap); if (!$objMap) { return false; } $arrMap = $objMap->row(); $arrMap['language'] = $GLOBALS['TL_LANGUAGE']; $arrMap['mapSize'] = deserialize($arrMap['mapSize']); $arrMap['mapSize'][2] = $arrMap['mapSize'][2] == 'pcnt' ? '%' : $arrMap['mapSize'][2]; $arrMap['mapTypesAvailable'] = deserialize($arrMap['mapTypesAvailable']); $arrMap['center'] = str_replace(' ', '', $arrMap['center']); $arrMap['draggable'] = $arrMap['draggable'] ? 'true' : 'false'; $arrMap['scrollwheel'] = $arrMap['scrollwheel'] ? 'true' : 'false'; $arrMap['disableDoubleClickZoom'] = $arrMap['disableDoubleClickZoom'] ? 'true' : 'false'; // parameters overwritten? if (is_array($arrParams) && count($arrParams) > 0) { foreach ($arrParams as $k => $v) { switch ($k) { case 'mapSize': if (is_array($v) && $v[0] > 0 && $v[1] > 0) { $arrMap[$k] = $v; } break; case 'zoom': if ($v > 0) { $arrMap[$k] = $v; } break; default: $arrMap[$k] = $v; break; } } } // generate static map begin $arrMap['staticMap'] = '<img src="http' . (\Environment::get('ssl') ? 's' : '') . '://maps.google.com/maps/api/staticmap?center=' . $arrMap['center'] . '&zoom=' . $arrMap['zoom'] . '&maptype=' . strtolower($arrMap['mapTypeId']) . '&sensor=' . ($arrMap['sensor'] ? 'true' : 'false') . '&language=' . $arrMap['language'] . '&size='; if ($arrMap['mapSize'][2] == 'px') { $arrMap['staticMap'] .= $arrMap['mapSize'][0] . 'x' . $arrMap['mapSize'][1]; } else { $arrMap['staticMap'] .= '800x600'; } // get elements data $arrMap['elements'] = array(); $objElements = \delahaye\googlemaps\ElementModel::findBy('pid', $intMap); if (is_object($objElements)) { $intCount = -1; while ($objElements->next()) { if ($objElements->published) { $intCount++; $tmpElement = self::getInstance()->getElementData($intMap, $intCount, $objElements->row()); $arrMap['staticMap'] .= $tmpElement['staticMapPart']; unset($tmpElement['staticMapPart']); $arrMap['elements'][] = $tmpElement; } } } // bundle the markers to positions in static maps, max 5 icons $intIcon = 1; foreach (self::$arrMarkers as $k => $v) { if ($intIcon <= 5) { $arrMap['staticMap'] .= '&' . $k . implode('|', $v); $intIcon++; } } // generate static map end $arrMap['staticMap'] .= '" alt="' . $GLOBALS['TL_LANG']['tl_dlh_googlemaps']['labels']['noscript'] . '"' . $strTagEnding; $arrMap['tabsCode'] = self::getTabsCode($intMap); return $arrMap; }
/** * Update the palettes * @param object */ public function updatePalette(DataContainer $dc) { $objElement = \delahaye\googlemaps\ElementModel::findByPk($dc->id); if ($objElement && \Input::get('act') == 'edit') { if ($objElement->type == 'MARKER') { if ($objElement->markerType == 'SIMPLE') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['fields']['fillColor']['eval']['mandatory'] = false; if ($objElement->markerAction == 'LINK') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERSIMPLE'] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERSIMPLELINK']; } elseif ($objElement->markerAction == 'INFO') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERSIMPLE'] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERSIMPLEINFO']; } } elseif ($objElement->markerType == 'ICON') { if ($objElement->markerAction == 'LINK') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERICON'] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERICONLINK']; } elseif ($objElement->markerAction == 'INFO') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERICON'] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['MARKERICONINFO']; } } } elseif ($objElement->type != 'INFOWINDOW' && $objElement->type != 'POLYLINE') { if ($objElement->type == 'KML') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes'][$objElement->type] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes']['KML']; } elseif ($objElement->markerAction == 'LINK') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes'][$objElement->type] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes'][$objElement->type . 'LINK']; } elseif ($objElement->markerAction == 'INFO') { $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes'][$objElement->type] = $GLOBALS['TL_DCA']['tl_dlh_googlemaps_elements']['palettes'][$objElement->type . 'INFO']; } } } }