Opened 11 years ago

Closed 11 years ago

#21606 closed Bug (fixed)

OSMWidget overrides map position passed to widget constructor

Reported by: jgoclawski Owned by: jgoclawski
Component: GIS Version: 1.6
Severity: Normal Keywords: gis, osmwidget
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When you pass default_lon or default_lat in attrs dictionary to OSMWidget constructor, it doesn't work as expected. Passed values are overriden by those fixed in the OSMWidget class.

The defaults are: default_lon = 5, default_lat = 47 and you cannot change them, unless you create a a new widget class derived from OSMWidget.

Example:

If you want to set e.g. map_width, you can do this with the BaseGeometryWidget:

coordinates = forms.PointField(widget=widgets.BaseGeometryWidget(
    attrs={'map_width': 100}
))

and it is used instead of default 600 value declared in BaseGeometryWidget.

But if you wanted to set OSMWidget's default_lon or default_lat, you would expect this should work:

coordinates = forms.PointField(widget=widgets.OSMWidget(
    attrs={'default_lon': 11,
           'default_lat': 12}
))

Well... it doesn't work. You will get a map rendered with default_lon = 5, default_lat = 47.

I'm preparing a GitHub pull request solving this issue.

Change History (6)

comment:1 by jgoclawski, 11 years ago

Owner: changed from nobody to jgoclawski
Status: newassigned

in reply to:  description comment:2 by jgoclawski, 11 years ago

Has patch: set

Link to the Github branch with a fix for this issue: https://github.com/jgoclawski/django/commits/ticket_21606

in reply to:  description comment:3 by jgoclawski, 11 years ago

comment:4 by Claude Paroz, 11 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Claude Paroz, 11 years ago

Triage Stage: AcceptedReady for checkin

Just waiting an answer about the commit https://github.com/jgoclawski/django/commit/cc3ddbf9718d

comment:6 by Claude Paroz <claude@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 2ddf1fc50f8fbb26ce5c6b9115111564bf21248c:

Fixed #21606 -- Fixed default_lat and default_lon override in OSMWidget

Note: See TracTickets for help on using tickets.
Back to Top