Ticket #10480: dynamic_icons.diff

File dynamic_icons.diff, 1.9 KB (added by jbronn, 16 years ago)

Make icons a property

  • 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]
    76 
    7774        # If GMarker, GPolygons, and/or GPolylines are used the zoom will be
    7875        # automatically calculated via the Google Maps API.  If both a zoom
    7976        # level and a center coordinate are provided with polygons/polylines,
     
    143140        "Returns XHTML information needed for IE VML overlays."
    144141        return mark_safe('<html xmlns="http://www.w3.org/1999/xhtml" %s>' % self.xmlns)
    145142
     143    @property
     144    def icons(self):
     145        "Returns a sequence of GIcon objects in this map."
     146        return [marker.icon for marker in self.markers if marker.icon]
     147
    146148class GoogleMapSet(GoogleMap):
    147149
    148150    def __init__(self, *args, **kwargs):
     
    173175        else:
    174176            self.maps = args
    175177
    176         # Creating the icons sequence from every map in this set.
    177         self.icons = []
    178         for map in self.maps:
    179             self.icons.extend(map.icons)
    180 
    181178        # Generating DOM ids for each of the maps in the set.
    182179        self.dom_ids = ['map%d' % i for i in xrange(len(self.maps))]
    183180
     
    220217        # `google-multi.js`, which calls the load routines for
    221218        # each one of the individual maps in the set.
    222219        return mark_safe('onload="%s.load()"' % self.js_module)
     220
     221    @property
     222    def icons(self):
     223        "Returns a sequence of all icons in each map of the set."
     224        icons = []
     225        for map in self.maps: icons.extend(map.icons)
     226        return icons
     227       
Back to Top