MapModelForm not using options?

12 views
Skip to first unread message

Terry Brown

unread,
Jan 11, 2011, 9:38:14 PM1/11/11
to olwi...@googlegroups.com
First - thanks for this great widget, very useful.

I have a MapModelForm, but it doesn't seem to be responding to options in Meta (Django 1.3 beta 1, olwidget 0.4):

class SiteForm(MapModelForm):

class Meta:
model = Site
exclude = ('next', 'prev', 'centroid',) # for now, don't want people br
options = {
'layers': ['google.satellite', 'google.streets', 'google.physical',
'google.hybrid', 'osm.mapnik', 've.road', 've.shaded',
've.aerial', 've.hybrid',],
'default_lat': 45,
'default_lon': -87,
'map_div_style': {'width': '900px', 'height': '640px'},
'map_options': {
'controls': ['LayerSwitcher', 'Navigation', 'PanZoom', 'Attribut
'ScaleLine'],
}

}

centroid isn't a field I'm interested in, the other geometry field is being edited by olwidget on the form, works fine, but it's just the default map with OpenStreetMap, and for this app. photography would make a much better background. Anything obviously wrong?

I have the google API key in settings, and all these layers working in a vanilla OpenLayers map in the same app.

It looks like form.media isn't writing as much as I'd expect into the page, but then I'm not sure what it is supposed to write - should there be script links to google API etc? Also firebug isn't catching any errors.

Thanks,
Terry

Charlie DeTar

unread,
Jan 13, 2011, 9:22:17 PM1/13/11
to olwi...@googlegroups.com
On 01/11/2011 09:38 PM, Terry Brown wrote:
> It looks like form.media isn't writing as much as I'd expect into the page, but then I'm not sure what it is supposed to write - should there be script links to google API etc? Also firebug isn't catching any errors.

Can you send the html/javascript that is output by {{ form.media }} and
{{ form }}?

What you should see is the google API links and such output by
form.media and the map constructor with options from {{ form }}.

I also haven't done much testing with 1.3 alpha; I've been tracking 1.2,
but I don't know of any reasons why things shouldn't work there.

best,
Charlie

Terry Brown

unread,
Jan 15, 2011, 1:06:12 PM1/15/11
to olwi...@googlegroups.com
On Sat, 15 Jan 2011 11:56:24 -0600
Terry Brown <terry_...@yahoo.com> wrote:

> hmm, so it's like the options aren't getting through from Meta. I'll try and run it on 1.2

Same result in 1.2.4, looked at my code again and it's definitely using the class SiteForm(MapModelForm) as posted... not sure what else could be interfering.

Cheers -Terry

Charlie DeTar

unread,
Jan 15, 2011, 1:50:33 PM1/15/11
to olwi...@googlegroups.com

Thanks muchly, it was a total bug; the options dict was indeed not being
read.

I've fixed this with the latest trunk at
https://github.com/yourcelf/olwidget.git , and added a test case for it.

-charlie

Terry Brown

unread,
Jan 15, 2011, 6:28:15 PM1/15/11
to olwi...@googlegroups.com
On Sat, 15 Jan 2011 13:50:33 -0500
Charlie DeTar <cha...@gmail.com> wrote:

> I've fixed this with the latest trunk at
> https://github.com/yourcelf/olwidget.git , and added a test case for it.

Fantastic - thanks - works great now.

Cheers -Terry

Reply all
Reply to author
Forward
0 new messages