/** * AddressBook * * @copyright (c) AddressBook Development Team * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html * @package AddressBook */ function smarty_function_AddressShowGmap($params, &$smarty) { $dom = ZLanguage::getModuleDomain('AddressBook'); $assign = isset($params['assign']) ? $params['assign'] : null; $directions = ''; if (isset($params['directions'])) { $directions = '<a href="http://maps.google.com/maps?f=d&daddr=' . $params['lat_long']; if (isset($params['zoomlevel'])) { $directions .= '&z=' . $params['zoomlevel']; } $directions .= '" target="_blank">' . __('Get directions to this location', $dom) . '</a>'; } if (!empty($directions)) { $directions = '<div>' . $directions . '</div>'; } include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php'; $map_id = 'googlemap'; if (isset($params['mapid'])) { $map_id .= $params['mapid']; } $app_id = 'ZikulaAddressBook'; $map = new GoogleMapAPI($map_id, $app_id); if (isset($params['maptype'])) { $map->setMapType($params['maptype']); // hybrid, satellite, terrain, roadmap } if (isset($params['zoomlevel'])) { $map->setZoomLevel($params['zoomlevel']); } $map->setTypeControlsStyle('dropdown'); $map->setWidth(isset($params['width']) && $params['width'] ? $params['width'] : '100%'); $map->setHeight(isset($params['height']) && $params['height'] ? $params['height'] : '400px'); // handle one (center) point if (isset($params['lat_long'])) { $arrLatLong = explode(',', $params['lat_long']); $map->setCenterCoords($arrLatLong[1], $arrLatLong[0]); $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $params['title'], $params['html'], $params['tooltip'], $params['icon'], $params['iconshadow']); } // API key if (isset($params['api_key'])) { $map->setApiKey($params['api_key']); } // handle array of points if (isset($params['points'])) { foreach ($params['points'] as $point) { $arrLatLong = explode(',', $point['lat_long']); $map->addMarkerByCoords($arrLatLong[1], $arrLatLong[0], $point['title'], $point['html'], $point['tooltip'], $point['icon'], $point['iconshadow']); } } // load the map $map->enableOnLoad(); if ($assign) { $result = $map->getHeaderJS() . $map->getMapJS() . $directions . $map->printMap() . $map->printOnLoad(); $smarty->assign($assign, $result); } else { PageUtil::addVar('rawtext', $map->getHeaderJS()); PageUtil::addVar('rawtext', $map->getMapJS()); return $directions . $map->printMap() . $map->printOnLoad(); } }
function get_geodata() { if (!SecurityUtil::checkPermission('AddressBook::', "::", ACCESS_EDIT)) { AjaxUtil::error($this->__('Error! No authorization to access this module.')); } $val_1 = FormUtil::getPassedValue('val_1', NULL, 'GETPOST'); $val_2 = FormUtil::getPassedValue('val_2', NULL, 'GETPOST'); $val_3 = FormUtil::getPassedValue('val_3', NULL, 'GETPOST'); $val_4 = FormUtil::getPassedValue('val_4', NULL, 'GETPOST'); //GMaps test include_once 'modules/AddressBook/lib/vendor/GMaps/GoogleMapV3.php'; $key = ModUtil::getVar('AddressBook', 'google_api_key'); $map = new GoogleMapAPI(); $map->setApiKey($key); $geocode = $map->getGeocode($val_1 . ', ' . $val_2 . ', ' . $val_3 . ', ' . $val_4); if (isset($geocode['lat']) && isset($geocode['lon'])) { $result = $geocode['lat'] . ',' . $geocode['lon']; } else { $result = ''; } if (FormUtil::getPassedValue('plane', NULL, 'GETPOST')) { return $result; } return new Zikula_Response_Ajax(array('lat_lon' => $result, 'result' => $result ? true : false)); }