Changeset 3156
- Timestamp:
- 07/19/2008 06:42:22 PM (5 months ago)
- Files:
-
- 1 modified
-
trunk/modules/gmaps/libraries/Gmap.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/gmaps/libraries/Gmap.php
r3151 r3156 15 15 * Retrieves the latitude and longitude of an address. 16 16 * 17 * @param stringaddress18 * @return arraylongitude, latitude17 * @param string $address address 18 * @return array longitude, latitude 19 19 */ 20 20 public static function address_to_ll($address) … … 37 37 * ! Results of this method are cached for 1 day. 38 38 * 39 * @param stringadress40 * @return objectSimpleXML39 * @param string $address adress 40 * @return object SimpleXML 41 41 */ 42 42 public static function address_to_xml($address) … … 57 57 else 58 58 { 59 // Get the API key60 $api_key = Config::item('gmaps.api_key');61 62 // Send the address URL encoded63 $addresss = rawurlencode($address);64 65 59 // Disable error reporting while fetching the feed 66 60 $ER = error_reporting(~E_NOTICE); … … 72 66 '&output=xml'. 73 67 '&oe=utf-8'. 74 '&key='. $api_key.75 '&q='.rawurlencode($address) 68 '&key='.Config::item('gmaps.api_key'). // Get the API key 69 '&q='.rawurlencode($address) // Send the address URL encoded 76 70 ); 77 71 … … 97 91 * Returns an image map 98 92 * 99 * @param mixed$lat latitude or an array of marker points100 * @param float$lon longitude101 * @param integer $zoom zoom level (1-16)102 * @param string $type map type (roadmap or mobile)103 * @param integer $width map width104 * @param integer $height map height105 * @return string93 * @param mixed $lat latitude or an array of marker points 94 * @param float $lon longitude 95 * @param integer $zoom zoom level (1-16) 96 * @param string $type map type (roadmap or mobile) 97 * @param integer $width map width 98 * @param integer $height map height 99 * @return string 106 100 */ 107 101 public static function static_map($lat = 0, $lon = 0, $zoom = 6, $type = 'roadmap', $width = 300, $height = 300) … … 142 136 protected $center; 143 137 protected $control; 138 protected $type_control = FALSE; 139 140 // Map types 141 protected $types = array(); 144 142 145 143 // Map markers … … 149 147 * Set the GMap center point. 150 148 * 151 * @param stringHTML map id attribute152 * @param arrayarray of GMap constructor options153 * @return void149 * @param string $id HTML map id attribute 150 * @param array $options array of GMap constructor options 151 * @return void 154 152 */ 155 153 public function __construct($id = 'map', $options = NULL) … … 163 161 * Return GMap javascript url 164 162 * 165 *166 163 * @return string 167 164 */ … … 175 172 * 176 173 * @chainable 177 * @param floatlatitude178 * @param floatlongitude179 * @param integerzoom level (1-16)180 * @return object174 * @param float $lat latitude 175 * @param float $lon longitude 176 * @param integer $zoom zoom level (1-16) 177 * @return object 181 178 */ 182 179 public function center($lat, $lon, $zoom = 6) … … 192 189 * 193 190 * @chainable 194 * @param stringsmall or large195 * @return object191 * @param string $size small or large 192 * @return object 196 193 */ 197 194 public function controls($size = NULL) … … 202 199 return $this; 203 200 } 201 202 /** 203 * Set the GMap type controls. 204 * by default renders G_NORMAL_MAP, G_SATELLITE_MAP, and G_HYBRID_MAP 205 * 206 * @chainable 207 * @param string $type map type 208 * @param string $action add or remove map type 209 * @return object 210 */ 211 public function types($type = NULL, $action = 'remove') 212 { 213 $this->type_control = TRUE; 214 215 $types = array 216 ( 217 'G_NORMAL_MAP','G_SATELLITE_MAP','G_HYBRID_MAP','G_PHYSICAL_MAP' 218 ); 219 220 if ($type !== NULL and in_array($type, $types, true)) 221 { 222 // Set the map type and action 223 $this->types[$type] = (strtolower($action) === 'remove') ? 'remove' : 'add'; 224 } 225 226 return $this; 227 } 204 228 205 229 /** … … 207 231 * 208 232 * @chainable 209 * @param float$lat latitude210 * @param float$lon longitude211 * @param string$html HTML for info window212 * @return object233 * @param float $lat latitude 234 * @param float $lon longitude 235 * @param string $html HTML for info window 236 * @return object 213 237 */ 214 238 public function add_marker($lat, $lon, $html = '') … … 224 248 * 225 249 * @param string $template template name 226 * @return string250 * @return string 227 251 */ 228 252 public function render($template = 'gmaps/javascript') … … 233 257 // Map 234 258 $map = 'var map = new google.maps.Map2(document.getElementById("'.$this->id.'"));'; 235 259 236 260 // Map controls 237 261 $controls = empty($this->control) ? '' : 'map.addControl(new google.maps.'.$this->control.'MapControl());'; 262 263 // Map Types 264 if ($this->type_control === TRUE) 265 { 266 if (count($this->types) > 0) 267 { 268 foreach($this->types as $type => $action) 269 $controls .= 'map.'.$action.'MapType('.$type.');'; 270 } 271 272 $controls .= 'map.addControl(new google.maps.MapTypeControl());'; 273 } 238 274 239 275 // Map centering
