Opened 15 years ago
Closed 3 years ago
#11634 closed Bug (invalid)
OpenLayers default position
Reported by: | Mattias Dalkvist | Owned by: | nobody |
---|---|---|---|
Component: | GIS | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | semente+djangoproject@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The openlayers.js templet don't take the display projection setting from the GeoModelAdmin classes in to consideration when applying the default position.
Fore example then the display projection is sett to 4326 (wgs83 standard lon/lat) and the map projection is sett to 900913 (the "google projection").
Then it is reasonable to expect the default position to be in the display projection and not the map projection.
The supplied patch checks to see if the display_projection is sett, if it is then adds a transformation call (from display projection to map projection) when the default position is used, in the openlayers.js
Attachments (1)
Change History (10)
by , 15 years ago
Attachment: | openlayers.diff added |
---|
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 15 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Needs tests: | set |
---|---|
Severity: | → Normal |
Type: | → Bug |
comment:4 by , 13 years ago
UI/UX: | unset |
---|
comment:6 by , 9 years ago
Claude, could you confirm there is value in keeping this ticket open given it hasn't seen activity in 6 years?
comment:7 by , 9 years ago
The reporter was right and the issue might still be accurate (we have some similar center conversion code in OLMapWidget.js).
However, I'm not so much interested in fixing this, as I'd like to see openlayer.js disappear. But that would mean deprecating GeoModelAdmin
as a whole and I'm not sure we can do this now without loosing some functionalities.
comment:8 by , 3 years ago
Since I marked #11094 as a duplicate of this one, I wanted to copy over this work-around that might be useful to people (as it was for me):
jbronn wrote in #11094 comment 4:
The
default_lon
anddefault_lat
are not working for you becauseOSMGeoAdmin
uses a different projection system thanGeoModelAdmin
. Specifically,OSMGeoAdmin
uses the so-called "Google" projection (SRID=900913) andGeoModelAdmin
uses WGS84 (SRID=4326). As such, just transform yourdefault_lon
anddefault_lat
values to 900913:
>>> from django.contrib.gis.geos import Point >>> pnt = Point(lon, lat, srid=4326) >>> pnt.transform(900913) >>> default_lon, default_lat = pnt.coords
These days, I would use 3857 instead of 900913 in the .transform().
comment:9 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
GeoModelAdmin
and OSMGeoAdmin
are deprecated (see 4555aa0a489cb9dcf764edf12339097cdfa5ff84).
Change UI/UX from NULL to False.