Changeset 3199 for trunk/modules
- Timestamp:
- 07/23/2008 11:44:44 AM (4 months ago)
- Location:
- trunk/modules/gmaps
- Files:
-
- 3 modified
-
controllers/gmaps_demo.php (modified) (1 diff)
-
libraries/Gmap.php (modified) (1 diff)
-
libraries/Gmap_Marker.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/gmaps/controllers/gmaps_demo.php
r3193 r3199 28 28 29 29 // Add a new marker 30 $map->add_marker(44.9801, -93.2519, '<strong>Minneapolis, MN</strong><p>Hello world!</p>' );30 $map->add_marker(44.9801, -93.2519, '<strong>Minneapolis, MN</strong><p>Hello world!</p>', array('draggable' => true, 'bouncy' => true)); 31 31 32 32 View::factory('gmaps/api_demo')->set(array('api_url' => Gmap::api_url(), 'map' => $map->render()))->render(TRUE); -
trunk/modules/gmaps/libraries/Gmap.php
r3195 r3199 280 280 * @return object 281 281 */ 282 public function add_marker($lat, $lon, $html = '' )282 public function add_marker($lat, $lon, $html = '', $options = array()) 283 283 { 284 284 // Add a new marker 285 $this->markers[] = new Gmap_Marker($lat, $lon, $html );285 $this->markers[] = new Gmap_Marker($lat, $lon, $html, $options); 286 286 287 287 return $this; -
trunk/modules/gmaps/libraries/Gmap_Marker.php
r3145 r3199 9 9 public $latitude; 10 10 public $longitude; 11 12 // Marker Options 13 protected $options = array(); 14 protected $valid_options = array 15 ( 16 'dragCrossMove', 17 'title', 18 'clickable', 19 'draggable', 20 'bouncy', 21 'bounceGravity', 22 'autoPan' 23 ); 11 24 12 25 /** … … 18 31 * @return void 19 32 */ 20 public function __construct($lat, $lon, $html )33 public function __construct($lat, $lon, $html, $options = array()) 21 34 { 22 35 if ( ! is_numeric($lat) OR ! is_numeric($lon)) … … 29 42 // Set the info window HTML 30 43 $this->html = $html; 44 45 if (count($options) > 0) 46 { 47 foreach ($options as $option => $value) 48 { 49 if (in_array($option, $this->valid_options, true)) 50 $this->options[$option] = $value; 51 } 52 } 31 53 } 32 54 … … 37 59 38 60 $output = array(); 39 $output[] = 'var m = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.') );';61 $output[] = 'var m = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), '.json_encode($this->options).');'; 40 62 if ($html = $this->html) 41 63 {
