Closed skyl closed 14 years ago
Hmmm, I see your point, this could be useful. Of course, you could just subclass GeoModelAdmin with this implementation... but I can see it being useful, in general, to support fields and callables.
I agree that the solution seems a little inelegant. I'll think on it and see if I can come up with another way. Let me know if you think of one.
Hey,
I've implemented this in the latest master in the following way:
def get_changelist_map(self, cl):
"""
Display a map in the admin changelist, with info popups
"""
if self.list_map:
info = []
for obj in cl.get_query_set():
# Transform the fields into one projection.
geoms = []
for field in self.list_map:
geom = getattr(obj, field)
if callable(geom):
geom = geom()
geoms.append(geom)
for geom in geoms:
geom.transform(int(DEFAULT_PROJ))
Let me know if you encounter any trouble with this implementation.
I did this in my branch; I don't like the solution but it works. I can make a branch and commit the change if you are interested. The reason this is important is you can use the http://geodjango.org/docs/geos.html#simplify-tolerance-0-0-preserve-topology-false so when you have 600 very complicated polygons you can render them without crippling the browser.