Thursday, 23 April 2015

web mapping - Django PolygonField: how to display on map?


Extremely beginner question.


I have a GeoDjango model with a MultiPolygonField. How do I retrieve the value of this field and display it as a polygon on a map?


class county(models.Model):

cd = models.CharField(max_length=10)
geom = models.MultiPolygonField(srid=27700)
objects = models.GeoManager()

def lsoa(request, code):
county = get_object_or_404(county.objects, cd=code)
return render_to_response('county.html', { 'county': county }, context_instance = RequestContext(request))

I know GeoJson is involved somewhere along the line, but I'm struggling with to get it out of Django, and with how to display it.




No comments:

Post a Comment