Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.70 KB  |  hits: 38  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Google Map V3 Cakephp helper and multiple markers
  2. <?php
  3. echo $this->GoogleMapV3->map();
  4. foreach ($allcondos as $condo) {
  5.     $options = array(
  6.     'lat' => $condo['Unit']['lat'],
  7.     'lng' => $condo['Unit']['lon']
  8.     );
  9.     $this->GoogleMapV3->addMarker($options);
  10. }
  11. ?>
  12.        
  13. foreach ($allcondos as $condo) {
  14.     $lat=$condo['Unit']['lat'];
  15.     $lon=$condo['Unit']['lon'];
  16.     $options = array(
  17.     'lat' => $lat,
  18.     'lng' => $lon
  19.     );
  20.     $this->GoogleMapV3->addMarker($options);
  21. }
  22.        
  23. <?php  
  24.     class AppController extends Contoller{
  25.         public $helpers = array('Html','Javascript','GoogleMapV3');
  26.     }  
  27. ?>
  28.        
  29. <?php  
  30.     class DemoController extends AppContoller{
  31.  
  32.         function map() {
  33.             $this->helpers[] = 'GoogleMapV3';
  34.             #   rest of your code      
  35.         }
  36.     }  
  37. ?
  38.        
  39. <?php
  40.     echo '<script type="text/javascript" src="'.$this->GoogleMapV3->apiUrl().'"></script>';
  41. ?>
  42.        
  43. <?php echo $this->GoogleMapV3->map(array('div'=>array('id'=>'my_map', 'height'=>'400', 'width'=>'100%'))); ?>
  44.        
  45. <?php echo $this->GoogleMapV3->map(array('map'=>array(
  46.             'defaultLat' => 40, # only last fallback, use Configure::write('Google.lat', ...); to define own one
  47.             'defaultLng' => -74, # only last fallback, use Configure::write('Google.lng', ...); to define own one
  48.             'defaultZoom' => 5,
  49.         ),'div'=>array('id'=>'my_map', 'height'=>'400', 'width'=>'100%'))); ?>
  50.        
  51. <?php  
  52.     $options = array(
  53.     'lat'=>40.770272,
  54.     'lng'=>-73.974037,
  55.         'title' => 'Some title', # optional
  56.         'content' => '<b>HTML</b> Content for the Bubble/InfoWindow' # optional
  57.     );
  58.     $this->GoogleMapV3->addMarker($options);
  59. ?>
  60.        
  61. <?php echo $this->GoogleMapV3->script() ?>