开发者

OpenLayer+GeoJSON+Django

Hi i try to do that example http://openlayers.org/dev/examples/all-overlays.html in my django application. I use test server. To access roads.json file in urls.py i wrote

(r'^data/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': '/home/xaver/geodjango/data'}),

I changed the html page so that it displays map created by OpenLayer (according text of example), picture located in directory data and also html uses CSS file located in data directory. With picture and CSS file all runs normally, but there is no map (just empty rectangle like when picture on server not found). When I wri开发者_Go百科te in the address bar of browser http://127.0.0.1:8000/data/1.png i see my image, http://127.0.0.1:8000/data/style.css i see CSS file, but when i write http://127.0.0.1:8000/data/roads.json browser says that the contents of a binary file and that it can save.


Get firebug for firefox, and use the 'net' tab to see what your openlayers javascript is really trying to get. I suspect either something is going '404 not found' or you've a cross-domain problem (a web page on 127.0.0.1:8000 cant get anything from mydomain.example.com:8000 even if they are the same machine). Firebug will sort you out.

Will also show Javascript errors on its console tab - could be one of those too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜