开发者

display MultiPolygonField data on Geodjango/OpenLayers

开发者 https://www.devze.com 2022-12-24 23:20 出处:网络
I\'m a Geodjango novice and would like to get some help on the following: I have a MultiPolygonField field, for a GeoDjango application, and would like to display it on my view as cool as it gets dis

I'm a Geodjango novice and would like to get some help on the following:

I have a MultiPolygonField field, for a GeoDjango application, and would like to display it on my view as cool as it gets displayed on django admin

Say for example I have

def index(request):
    "Index,main view"
    border = WorldBorders.objects.get(name='Italy')
    return r开发者_如何学运维ender_to_response('world/index.html', {'user': request.user, 'border': border}, context_instance=RequestContext(request)) 

then on world/index.html, what is the way to display the border, as it would be on django admin?

Thanks in advance for all replies!


I suggest just taking something from http://openlayers.org/dev/examples/ and changing it to suit your needs. Convert the multipolygon field to JSON data, read in the JSON data in javascript (see the OL parser documentation) and display it on the map.

Others may suggest some way of leveraging the django-admin js, but I never found that to be sufficient.

If you have specific questions about any of these steps, just ask another question and hopefully I'll be able to answer.


http://code.google.com/p/geodjango-basic-apps seems a nice start...

0

精彩评论

暂无评论...
验证码 换一张
取 消