Changeset 3191 for trunk/modules
- Timestamp:
- 07/22/2008 01:31:21 PM (4 months ago)
- Files:
-
- 1 modified
-
trunk/modules/gmaps/libraries/Gmap.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/gmaps/libraries/Gmap.php
r3181 r3191 75 75 76 76 // Load Cache 77 ($cache === NULL) and $cache = Cache::instance(); 78 77 if ($cache === NULL) 78 { 79 $cache = Cache::instance(); 80 } 81 79 82 // Address cache key 80 83 $key = 'gmap-address-'.sha1($address); … … 119 122 * @param mixed $lat latitude or an array of marker points 120 123 * @param float $lon longitude 121 * @param integer $zoom zoom level (1-1 6)124 * @param integer $zoom zoom level (1-19) 122 125 * @param string $type map type (roadmap or mobile) 123 126 * @param integer $width map width … … 172 175 // Map types 173 176 protected $types = array(); 177 protected $default_types = array 178 ( 179 'G_NORMAL_MAP','G_SATELLITE_MAP','G_HYBRID_MAP','G_PHYSICAL_MAP' 180 ); 174 181 175 182 // Map markers … … 196 203 * @param float $lat latitude 197 204 * @param float $lon longitude 198 * @param integer $zoom zoom level (1-16) 199 * @return object 200 */ 201 public function center($lat, $lon, $zoom = 6) 202 { 203 // Set center location and zoom 204 $this->center = array($lat, $lon, $zoom); 205 * @param integer $zoom zoom level (1-19) 206 * @param string $type default map type 207 * @return object 208 */ 209 public function center($lat, $lon, $zoom = 6, $type = 'G_NORMAL_MAP') 210 { 211 $zoom = min(0, max(19, abs($zoom))); 212 $type = ($type != 'G_NORMAL_MAP' AND in_array($type, $this->default_types, true)) ? $type : 'G_NORMAL_MAP'; 213 214 // Set center location, zoom and default map type 215 $this->center = array($lat, $lon, $zoom, $type); 205 216 206 217 return $this; … … 251 262 $this->type_control = TRUE; 252 263 253 $types = array 254 ( 255 'G_NORMAL_MAP','G_SATELLITE_MAP','G_HYBRID_MAP','G_PHYSICAL_MAP' 256 ); 257 258 if ($type !== NULL and in_array($type, $types, true)) 264 if ($type !== NULL AND in_array($type, $this->default_types, true)) 259 265 { 260 266 // Set the map type and action 261 $this->types[$type] = (strtolower($action) == ='remove') ? 'remove' : 'add';267 $this->types[$type] = (strtolower($action) == 'remove') ? 'remove' : 'add'; 262 268 } 263 269 … … 290 296 public function render($template = 'gmaps/javascript') 291 297 { 292 // Latitude, longitude, and zoom293 list ($lat, $lon, $zoom ) = $this->center;298 // Latitude, longitude, zoom and default map type 299 list ($lat, $lon, $zoom, $default_type) = $this->center; 294 300 295 301 // Map … … 315 321 316 322 // Map centering 317 $center = 'map.setCenter(new google.maps.LatLng('.$lat.', '.$lon.'), '.$zoom.' );';323 $center = 'map.setCenter(new google.maps.LatLng('.$lat.', '.$lon.'), '.$zoom.', '.$default_type.');'; 318 324 319 325 // Render the Javascript
