/** * 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(); } }
public function action_index() { require_once Kohana::find_file('vendor', 'php-googlemap/GoogleMap', 'php'); $this->before('/pages/maps'); $this->template->title = __('Map'); $height = Core::get('height', '100%'); $width = Core::get('width', '100%'); $map = new GoogleMapAPI(); $map->setWidth($width); $map->setHeight($height); $map->disableSidebar(); $map->setMapType('map'); $map->setZoomLevel(Core::get('zoom', core::config('advertisement.map_zoom'))); //$map->mobile = TRUE; $atributes = array("target='_blank'"); if (core::get('controls') == 0) { $map->disableMapControls(); $map->disableTypeControls(); $map->disableScaleControl(); $map->disableZoomEncompass(); $map->disableStreetViewControls(); $map->disableOverviewControl(); } //only 1 marker if (core::get('address') != '') { $map->addMarkerByAddress(core::get('address'), core::get('address')); } else { //last ads, you can modify this value at: general.feed_elements $ads = DB::select('a.seotitle')->select(array('c.seoname', 'category'), 'a.title', 'a.published', 'a.address')->from(array('ads', 'a'))->join(array('categories', 'c'), 'INNER')->on('a.id_category', '=', 'c.id_category')->where('a.status', '=', Model_Ad::STATUS_PUBLISHED)->where('a.address', 'IS NOT', NULL)->order_by('published', 'desc')->limit(Core::config('general.map_elements'))->as_object()->cached()->execute(); foreach ($ads as $a) { //d($a); if (strlen($a->address) > 3) { $url = Route::url('ad', array('category' => $a->category, 'seotitle' => $a->seotitle)); $map->addMarkerByAddress($a->address, $a->title, HTML::anchor($url, $a->title, $atributes)); } } //only center if not a single ad $map->setCenterCoords(Core::get('lon', core::config('advertisement.center_lon')), Core::get('lat', core::config('advertisement.center_lat'))); } $this->template->map = $map; }
/** * Output the google map * * @param string $text text for the "toggle" link that shows/hides the map. Set empty to omit * @param string $id used to set the IDs for the toggle href element ($id_toggle) and the map element ($id_data) * @param string $hide initial map state: "hide", "show", or "colrobox" * @param object $obj optional image/album object. Pass string for generic map and use callback to set points * @param function $callback optional callback function to set map options. */ function printGoogleMap($text = NULL, $id = NULL, $hide = NULL, $obj = NULL, $callback = NULL) { global $_zp_current_album, $_zp_current_image; if (is_null($obj)) { if (is_null($_zp_current_image)) { $obj = $_zp_current_album; } else { $obj = $_zp_current_image; } } if (is_null($obj)) { $MAP_OBJECT = NULL; return false; } if (is_object($obj)) { $type = $obj->table; $typeid = $obj->getID(); } else { $type = $obj; $typeid = ''; } if (is_null($text)) { $text = gettext('Google Map'); } if (empty($text)) { $hide = 'show'; } if (is_null($hide)) { $hide = getOption('gmap_display'); } if (!is_string($hide)) { if ($hide) { $hide = 'hide'; } else { $hide = 'show'; } } $MAP_OBJECT = new GoogleMapAPI($type . $typeid); $MAP_OBJECT->_minify_js = defined('RELEASE'); $MAP_OBJECT->setZoomLevel(getOption('gmap_zoom')); $MAP_OBJECT->setWidth(getOption('gmap_width')); $MAP_OBJECT->setHeight(getOption('gmap_height')); $MAP_OBJECT->setMapType(getOption('gmap_starting_map')); $mapcontrol = getOption('gmap_control'); if ($mapcontrol == 'none') { $MAP_OBJECT->disableTypeControls(); } else { $MAP_OBJECT->enableMapControls(); $MAP_OBJECT->setTypeControlsStyle($mapcontrol); $MAP_OBJECT->setControlSize(getOption('gmap_control_size')); $mapsallowed = array(); if (getOption('gmap_map')) { $mapsallowed[] = 'ROADMAP'; } if (getOption('gmap_hybrid')) { $mapsallowed[] = 'HYBRID'; } if (getOption('gmap_satellite')) { $mapsallowed[] = 'SATELLITE'; } if (getOption('gmap_terrain')) { $mapsallowed[] = 'TERRAIN'; } $MAP_OBJECT->setTypeControlTypes($mapsallowed); } switch ($type) { case 'images': if (getImageGeodata($obj, $MAP_OBJECT)) { break; } $MAP_OBJECT = NULL; return false; case 'albums': if (getAlbumGeodata($obj, $MAP_OBJECT)) { break; } $MAP_OBJECT = NULL; return false; default: break; } $type = $type . $typeid . '_'; if (is_null($id)) { $id = $type . 'googlemap'; } $id_toggle = $id . '_toggle'; $id_data = $id . '_data'; if (!is_null($callback)) { call_user_func($callback, $MAP_OBJECT); } echo $MAP_OBJECT->getMapJS(); switch ($hide) { case 'colorbox': $w = str_replace('px', '', $MAP_OBJECT->width) + 20; $h = str_replace('px', '', $MAP_OBJECT->height) + 20; if (function_exists('bzcompress')) { $method = 'bzip2'; $data = bzcompress(serialize($MAP_OBJECT)); } else { $method = 'gzip'; $data = gzcompress(serialize($MAP_OBJECT)); } $param = base64_encode($data); ?> <a href="javascript:<?php echo $id_data; ?> Colorbox();" title="<?php echo $text; ?> " class="google_map"> <?php echo $text; ?> </a> <div id="<?php echo $id_data; ?> " class="hidden_map"> <div id="<?php echo $id_data; ?> _map"> <?php echo $MAP_OBJECT->printOnLoad(); echo $MAP_OBJECT->printMap(); ?> </div> </div> <script type="text/javascript"> // <!-- <![CDATA[ function <?php echo $id_data; ?> Colorbox() { $('#<?php echo $id_data; ?> ').removeClass('hidden_map'); $.colorbox({href:"#<?php echo $id_data; ?> _map", inline:true, open:true}); $('#<?php echo $id_data; ?> ').addClass('hidden_map'); } $(document).ready(function(){ $("#<?php echo $id_data; ?> _map").colorbox({iframe:true, innerWidth:'<?php echo $w; ?> px', innerHeight:'<?php echo $h; ?> px'}); }); // ]]> --> </script> <?php break; case 'hide': ?> <script type="text/javascript"> // <!-- <![CDATA[ function toggle_<?php echo $id_data; ?> () { if ($('#<?php echo $id_data; ?> ').hasClass('hidden_map')) { $('#<?php echo $id_data; ?> ').removeClass('hidden_map'); } else { $('#<?php echo $id_data; ?> ').addClass('hidden_map'); } } // ]]> --> </script> <a id="<?php echo $id_toggle; ?> " href="javascript:toggle_<?php echo $id_data; ?> ();" title="<?php echo gettext('Display or hide the Google Map.'); ?> "> <?php echo $text; ?> </a> <div id="<?php echo $id_data; ?> " class="hidden_map"> <?php echo $MAP_OBJECT->printOnLoad(); echo $MAP_OBJECT->printMap(); ?> </div> <?php break; case 'show': ?> <a id="<?php echo $id_toggle; ?> " href="javascript:toggleMap('<?php echo $id_data; ?> ');" title="<?php echo gettext('Display or hide the Google Map.'); ?> "> <?php echo $text; ?> </a> <div id="<?php echo $id_data; ?> "> <?php echo $MAP_OBJECT->printOnLoad(); echo $MAP_OBJECT->printMap(); ?> </div> <?php break; } }
<!--<?php require_once 'header_php.php'; ?> --> <?php $map = new GoogleMapAPI('map'); $map->setAPIKey($googlemaps_key); $map->disableSidebar(); $map->setMapType('map'); $map->setWidth(510); $map->setHeight(350); $map->setMapType('hybrid'); $map->disableDirections(); $map->setZoomLevel(13); //$map->addMarkerByAddress('5186-F Longs Peak Road Berthoud Colorado 80513','','Colorado Water Jet<br>5186-F Longs Peak Road<br>Berthoud, Colorado 80513'); $map->addMarkerByCoords(-104.98301267623901, 40.34088546651259, '', 'Colorado Water Jet<br>5186 Longs Peak Road Unit F<br>Berthoud, Colorado 80513'); ?> <?php include 'header.php'; ?> <table align="center" border="0" cellpadding="0" cellspacing="0"> <tr valign='top'><td rowspan='3'>Colorado WaterJet<br>5186 Longs Peak Road Unit F<br>Berthoud, Colorado 80513</td><td rowspan='3'><img src="/images/clear.gif" height="1" width="60"></td> <td>970-532-5404</td></tr> <tr><td><a href="mailto:sales@coloradowaterjet.com">sales@coloradowaterjet.com</a></td></tr>
<?php //http://www.bradwedell.com/php-google-maps-api error_reporting(E_ALL ^ E_NOTICE); require_once "../include/GoogleApi/GoogleMap.php"; require_once "../include/GoogleApi/JSMin.php"; $gmap = new GoogleMapAPI(); $gmap->setWidth('100%'); $gmap->setHeight('90%');