Author: jbronn
Date: 2009-05-30 11:10:23 -0500 (Sat, 30 May 2009)
New Revision: 10865
Modified:
django/trunk/django/contrib/gis/maps/google/gmap.py
django/trunk/django/contrib/gis/maps/google/overlays.py
Log:
Fixed #11200 -- Now use a `set` data structure for `GoogleMap` icons so that
they aren't repeated in rendered JavaScript. Thanks to ludifan for ticket and
initial patch.
Modified: django/trunk/django/contrib/gis/maps/google/gmap.py
===================================================================
--- django/trunk/django/contrib/gis/maps/google/gmap.py 2009-05-29 05:28:40 UTC
(rev 10864)
+++ django/trunk/django/contrib/gis/maps/google/gmap.py 2009-05-30 16:10:23 UTC
(rev 10865)
@@ -143,7 +143,7 @@
@property
def icons(self):
"Returns a sequence of GIcon objects in this map."
- return [marker.icon for marker in self.markers if marker.icon]
+ return set([marker.icon for marker in self.markers if marker.icon])
class GoogleMapSet(GoogleMap):
@@ -221,6 +221,6 @@
@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)
+ icons = set()
+ for map in self.maps: icons |= map.icons
return icons
Modified: django/trunk/django/contrib/gis/maps/google/overlays.py
===================================================================
--- django/trunk/django/contrib/gis/maps/google/overlays.py 2009-05-29
05:28:40 UTC (rev 10864)
+++ django/trunk/django/contrib/gis/maps/google/overlays.py 2009-05-30
16:10:23 UTC (rev 10865)
@@ -231,6 +231,14 @@
self.iconanchor = iconanchor
self.infowindowanchor = infowindowanchor
+ def __cmp__(self, other):
+ return cmp(self.varname, other.varname)
+
+ def __hash__(self):
+ # XOR with hash of GIcon type so that hash('varname') won't
+ # equal hash(GIcon('varname')).
+ return hash(self.__class__) ^ hash(self.varname)
+
class GMarker(GOverlayBase):
"""
A Python wrapper for the Google GMarker object. For more information
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---