Changeset 3206
- Timestamp:
- 07/25/2008 08:29:59 AM (4 months ago)
- Location:
- trunk/modules/gmaps
- Files:
-
- 1 added
- 4 modified
-
controllers/gmaps_demo.php (modified) (2 diffs)
-
libraries/Gmap.php (modified) (3 diffs)
-
libraries/Gmap_Icon.php (added)
-
libraries/Gmap_Marker.php (modified) (3 diffs)
-
views/gmaps/javascript.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/gmaps/controllers/gmaps_demo.php
r3199 r3206 26 26 // Set the map center point 27 27 $map->center(0, 0, 1)->controls('large')->types('G_PHYSICAL_MAP', 'add'); 28 29 // Add a custom marker icon 30 $map->add_icon('tinyIcon', array 31 ( 32 'image' => 'http://labs.google.com/ridefinder/images/mm_20_red.png', 33 'shadow' => 'http://labs.google.com/ridefinder/images/mm_20_shadow.png', 34 'iconSize' => array('12', '20'), 35 'shadowSize' => array('22', '20'), 36 'iconAnchor' => array('6', '20'), 37 'infoWindowAnchor' => array('5', '1') 38 )); 28 39 29 40 // Add a new marker 30 $map->add_marker(44.9801, -93.2519, '<strong>Minneapolis, MN</strong><p>Hello world!</p>', array(' draggable' => true, 'bouncy' => true));41 $map->add_marker(44.9801, -93.2519, '<strong>Minneapolis, MN</strong><p>Hello world!</p>', array('icon' => 'tinyIcon', 'draggable' => true, 'bouncy' => true)); 31 42 32 43 View::factory('gmaps/api_demo')->set(array('api_url' => Gmap::api_url(), 'map' => $map->render()))->render(TRUE); … … 56 67 // Add a new marker 57 68 $map->add_marker($location->lat, $location->lon, 58 // Get the info window HTML 59 View::factory('gmaps/info_window')->bind('location', $location)->render()); 69 70 // Get the info window HTML 71 View::factory('gmaps/info_window')->bind('location', $location)->render()); 60 72 } 61 73 -
trunk/modules/gmaps/libraries/Gmap.php
r3199 r3206 179 179 'G_NORMAL_MAP','G_SATELLITE_MAP','G_HYBRID_MAP','G_PHYSICAL_MAP' 180 180 ); 181 182 // Markers icons 183 protected $icons = array(); 181 184 182 185 // Map markers … … 269 272 270 273 return $this; 274 } 275 276 /** 277 * Create a custom marker icon 278 * 279 * @chainable 280 * @param string $name icon name 281 * @param array $options icon options 282 * @return object 283 */ 284 public function add_icon($name, array $options) 285 { 286 // Add a new cusotm icon 287 $this->icons[] = new Gmap_Icon($name, $options); 288 289 return $this; 271 290 } 272 291 … … 330 349 'controls' => implode("\n", $controls), 331 350 'center' => $center, 351 'icons' => $this->icons, 332 352 'markers' => $this->markers, 333 353 )) -
trunk/modules/gmaps/libraries/Gmap_Marker.php
r3204 r3206 17 17 protected $valid_options = array 18 18 ( 19 'icon', 19 20 'dragCrossMove', 20 21 'title', … … 53 54 // Set marker options 54 55 if (in_array($option, $this->valid_options, true)) 55 $this->options[ $option] = $value;56 $this->options[] = "$option:$value"; 56 57 } 57 58 } … … 66 67 $marker = 'm'.++self::$id; 67 68 68 $output[] = 'var '.$marker.' = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), '.json_encode($this->options).');';69 $output[] = 'var '.$marker.' = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), {'.implode(",", $this->options).'});'; 69 70 if ($html = $this->html) 70 71 { -
trunk/modules/gmaps/views/gmaps/javascript.php
r3163 r3206 7 7 <?php echo $center, "\n" ?> 8 8 <?php echo $options->render(1), "\n" ?> 9 10 // Build custom marker icons 11 <?php foreach($icons as $icon): ?> 12 <?php echo $icon->render(1), "\n" ?> 13 <?php endforeach ?> 9 14 10 15 // Show map points 11 <?php foreach ($markers as $marker): ?>16 <?php foreach($markers as $marker): ?> 12 17 <?php echo $marker->render(1), "\n" ?> 13 18 <?php endforeach ?>
