Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #10480 -- made `icons` a property to add more flexibility.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10102 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9eb061b2c02a3f1c78c9d323498dffb97a713c32 1 parent 85733c5
Justin Bronn authored March 20, 2009

Showing 1 changed file with 12 additions and 8 deletions. Show diff stats Hide diff stats

  1. 20  django/contrib/gis/maps/google/gmap.py
20  django/contrib/gis/maps/google/gmap.py
@@ -71,9 +71,6 @@ def __init__(self, key=None, api_url=None, version=None,
71 71
                     else:
72 72
                         getattr(self, varname).append(overlay_class(overlay))
73 73
 
74  
-        # Pulling any icons from the markers.
75  
-        self.icons = [marker.icon for marker in self.markers if marker.icon]
76  
-
77 74
         # If GMarker, GPolygons, and/or GPolylines are used the zoom will be
78 75
         # automatically calculated via the Google Maps API.  If both a zoom
79 76
         # level and a center coordinate are provided with polygons/polylines,
@@ -143,6 +140,11 @@ def xhtml(self):
143 140
         "Returns XHTML information needed for IE VML overlays."
144 141
         return mark_safe('<html xmlns="http://www.w3.org/1999/xhtml" %s>' % self.xmlns)
145 142
 
  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
+
146 148
 class GoogleMapSet(GoogleMap):
147 149
 
148 150
     def __init__(self, *args, **kwargs):
@@ -173,11 +175,6 @@ def __init__(self, *args, **kwargs):
173 175
         else:
174 176
             self.maps = args
175 177
 
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  
-
181 178
         # Generating DOM ids for each of the maps in the set.
182 179
         self.dom_ids = ['map%d' % i for i in xrange(len(self.maps))]
183 180
 
@@ -220,3 +217,10 @@ def onload(self):
220 217
         # `google-multi.js`, which calls the load routines for
221 218
         # each one of the individual maps in the set.
222 219
         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

0 notes on commit 9eb061b

Please sign in to comment.
Something went wrong with that request. Please try again.