为 Leaflet 设置 SRID - Geodjango

Setting up a SRID to a Leaflet - Geodjango

我的 Postgres 数据库中有 31277 投影中的数据。 无论如何,我正在使用 Leaflet 地图与 Geodjango 一起展示它们。现在,我的数据在地图的某个地方移动了,所以我需要更改 Leaflet 地图的投影。

在文档中 (http://django-leaflet.readthedocs.io/en/latest/advanced.html) 只是为了将 SRID 属性添加到 LEAFLET_CONFIG 变量,我这样做了。喜欢这里:

LEAFLET_CONFIG = {
    'DEFAULT_ZOOM': 13,
    'MIN_ZOOM': 2,
    'MAX_ZOOM': 18,
    'SRID':31277
}

但是在我添加 SRID 属性后,当我尝试使用地图访问该页面时出现错误:

"GET /static/proj4js/31277.js HTTP/1.1" 404 1770

此外,我在 WGS84 - 4326 上遇到了同样的错误

根据您收到的错误路径判断,以 staticCONFIG subjectdjango-leaflet 的文档开头:

By default, django-leaflet will try to load the spatial reference from your static files at “proj4js/{{ srid }}.js”.

我建议配置您的 static file settings 和 运行

python manage.py collectstatic