Ticket #9204: stand_alone_icon_generation.diff

File stand_alone_icon_generation.diff, 1.5 KB (added by prairiedogg, 16 years ago)

Broke the statement that generates a maps icons from its marker list into its own stand alone method so that it may be called multiple times during the object's life cycle

  • django/contrib/gis/maps/google/gmap.py

     
    7171                    else:
    7272                        getattr(self, varname).append(overlay_class(overlay))
    7373
    74         # Pulling any icons from the markers.
    75         self.icons = [marker.icon for marker in self.markers if marker.icon]
     74        # Pull any icons from the markers.
     75        self._generate_icon_list()
    7676
    7777        # If GMarker, GPolygons, and/or GPolylines are used the zoom will be
    7878        # automatically calculated via the Google Maps API.  If both a zoom
     
    9090        if center is None: center = (0, 0)
    9191        self.center = center
    9292
     93    def _generate_icon_list(self):
     94        """
     95        Sets the icon list for this map in
     96            ``self.icons``
     97           
     98        This method is a stand alone so that it may be called again after the map
     99        object created (in case new markers are added to the map after its
     100        instantiation).
     101       
     102        """
     103        self.icons =  [marker.icon for marker in self.markers if marker.icon]
     104        return None
     105   
    93106    def render(self):
    94107        """
    95108        Generates the JavaScript necessary for displaying this Google Map.
    96109        """
     110        self._generate_icon_list()
    97111        params = {'calc_zoom' : self.calc_zoom,
    98112                  'center' : self.center,
    99113                  'dom_id' : self.dom_id,
Back to Top