Changeset 3204 for trunk/modules

Show
Ignore:
Timestamp:
07/24/2008 04:36:10 AM (4 months ago)
Author:
alexsancho
Message:

fix for #507, added marker unique id

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/gmaps/libraries/Gmap_Marker.php

    r3200 r3204  
    99        public $latitude; 
    1010        public $longitude; 
     11         
     12        // Marker ID 
     13        protected static $id = 0; 
    1114         
    1215        // Marker Options 
     
    6063                $tabs = empty($tabs) ? '' : str_repeat("\t", $tabs); 
    6164 
    62                 $output = array(); 
    63                 $output[] = 'var m = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), '.json_encode($this->options).');'; 
     65                // Marker ID 
     66                $marker = 'm'.++self::$id; 
     67 
     68                $output[] = 'var '.$marker.' = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), '.json_encode($this->options).');'; 
    6469                if ($html = $this->html) 
    6570                { 
    66                         $output[] = 'google.maps.Event.addListener(m, "click", function()'; 
     71                        $output[] = 'google.maps.Event.addListener('.$marker.', "click", function()'; 
    6772                        $output[] = '{'; 
    68                         $output[] = "\t".'m.openInfoWindowHtml('; 
     73                        $output[] = "\t".$marker.'.openInfoWindowHtml('; 
    6974                        $output[] = "\t\t'".implode("'+\n\t\t$tabs'", explode("\n", $html))."'"; 
    7075                        $output[] = "\t);"; 
    7176                        $output[] = '});'; 
    7277                } 
    73                 $output[] = 'map.addOverlay(m);'; 
     78                $output[] = 'map.addOverlay('.$marker.');'; 
    7479 
    7580                return implode("\n".$tabs, $output);