[Answered ]-OSMWidget Django form location coodinates are incorrect

1👍

You must explictly define the SRID in the form’s field. I’m not sure why this is the case (you’d think it would default to 4326 like the rest of Django/GeoDjango), but that’s the way it seems to be. Your code should read:

point = gis_forms.PointField(
    srid=4326,
    widget=gis_forms.OSMWidget(
        attrs={
            "map_width": 800,
            "map_srid": 4326,
            "map_height": 500,
            "default_lat": 49.246292,
            "default_lon": -123.116226,
            "default_zoom": 7,
        }
    ),
)

👤Simon

Leave a comment