为传单设置SRID-Geodjango [英] Setting up a SRID to a Leaflet - Geodjango
问题描述
我的Postgres DB中有31277投影的数据. 无论如何,我正在使用Leaflet地图与Geodjango一起显示它们.现在,我的数据在地图中向下移动了,所以我需要更改Leaflet地图的投影.
I have data in my Postgres DB which are in 31277 projection. Anyway, I am using Leaflet map to show them with Geodjango. Right now, my data are moved somewhere down in the map, so I need to change the projection of the Leaflet map.
在文档中( http://django-leaflet.readthedocs.io/zh_cn/latest/advanced.html )的编写只是为了将SRID属性添加到LEAFLET_CONFIG变量中,而我这样做.就像这里:
In documentation (http://django-leaflet.readthedocs.io/en/latest/advanced.html) is written just to add SRID attribute to LEAFLET_CONFIG variable, which I did. Like here:
LEAFLET_CONFIG = {
'DEFAULT_ZOOM': 13,
'MIN_ZOOM': 2,
'MAX_ZOOM': 18,
'SRID':31277
}
但是,当我添加SRID属性后,尝试通过地图访问该页面时出现错误:
But after I added SRID attribute I got an error when I tried to access to that page with a map:
"GET /static/proj4js/31277.js HTTP/1.1" 404 1770
此外,我对于WGS84-4326遇到相同的错误
Also, I get same error for the WGS84 - 4326
推荐答案
从得到的错误的路径开始,以 static 和上的django-leaflet
文档开头href ="http://django-leaflet.readthedocs.io/en/latest/advanced.html" rel ="nofollow noreferrer">配置主题:
Judging by the path of the error you are getting, that starts with static and the documentation of django-leaflet
on the CONFIG subject:
默认情况下,django-leaflet将尝试从静态文件"proj4js/{{srid}}.js"中加载空间参考.
By default, django-leaflet will try to load the spatial reference from your static files at "proj4js/{{ srid }}.js".
我建议配置您的静态文件设置并运行
I would suggest configuring your static file settings and run
python manage.py collectstatic
这篇关于为传单设置SRID-Geodjango的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!