Guest User

Untitled

a guest
May 28th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. def gpoly(poly, name, last=False):
  2. geom_object = GPolygon(fromstr(poly.wkt, srid=4326))
  3. if not last:
  4. event = GEvent('click',
  5. 'function() { location.href = "%s"}' % name.lower())
  6. geom_object.add_event(event)
  7.  
  8. def territory(request, name):
  9. children = None
  10. parent = Territory.objects.get(name__iexact=name, code='ADMD', type='A')
  11. children = territory.children.all()
  12. children_geom = []
  13. if children:
  14. for child in children:
  15. children_geom.append(gpoly(poly, territory.name, child))
  16.  
  17. gmap=GoogleMap(polygons=children_geom)
  18.  
  19. return render_to_response('geoview/territory.html',
  20. {'territory':territory,'children':children,
  21. 'gmap':gmap},
  22. context_instance=RequestContext(request),)
Add Comment
Please, Sign In to add comment