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
This commit is contained in:
Justin Bronn 2009-03-20 02:10:47 +00:00
parent 85733c5d51
commit 9eb061b2c0
1 changed files with 12 additions and 8 deletions

View File

@ -71,9 +71,6 @@ class GoogleMap(object):
else:
getattr(self, varname).append(overlay_class(overlay))
# Pulling any icons from the markers.
self.icons = [marker.icon for marker in self.markers if marker.icon]
# If GMarker, GPolygons, and/or GPolylines are used the zoom will be
# automatically calculated via the Google Maps API. If both a zoom
# level and a center coordinate are provided with polygons/polylines,
@ -143,6 +140,11 @@ class GoogleMap(object):
"Returns XHTML information needed for IE VML overlays."
return mark_safe('<html xmlns="http://www.w3.org/1999/xhtml" %s>' % self.xmlns)
@property
def icons(self):
"Returns a sequence of GIcon objects in this map."
return [marker.icon for marker in self.markers if marker.icon]
class GoogleMapSet(GoogleMap):
def __init__(self, *args, **kwargs):
@ -173,11 +175,6 @@ class GoogleMapSet(GoogleMap):
else:
self.maps = args
# Creating the icons sequence from every map in this set.
self.icons = []
for map in self.maps:
self.icons.extend(map.icons)
# Generating DOM ids for each of the maps in the set.
self.dom_ids = ['map%d' % i for i in xrange(len(self.maps))]
@ -220,3 +217,10 @@ class GoogleMapSet(GoogleMap):
# `google-multi.js`, which calls the load routines for
# each one of the individual maps in the set.
return mark_safe('onload="%s.load()"' % self.js_module)
@property
def icons(self):
"Returns a sequence of all icons in each map of the set."
icons = []
for map in self.maps: icons.extend(map.icons)
return icons