Using olwidget to select a geometry

11 views
Skip to first unread message

Dylan Verheul

unread,
May 23, 2011, 3:08:32 AM5/23/11
to olwi...@googlegroups.com
Case:

1 - I have a table with geometries
2 - I'd like to show a map (olwidget) with some of these geometries
3 - User should be able to select one of these geometries, textarea
fills with geom info
4 - And also have the option for user to draw a new geometry

I can't get #3 to work. Have tried various form configs. Displaying is
not a problem, but when user clicks ona defined geometry, nothing
happens to the textarea. Adding a new geometry is not a problem. Best
effort so far:

class TestForm(forms.Form):

def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)
fields = [
EditableLayerField({'geometry': [ 'point', 'linestring',
'polygon' ], 'name': 'Create new'}),
]
for location in Location.objects.all():
fields.append(InfoLayerField([[location.geom,
location.name]], {'name': location.key}))
self.fields['test'] = MapField(fields, { 'hide_textarea': False })

I don't mind spending a few more hours, but it seems someone must have
done this before. Anyone?

Dylan Verheul
http://dyve.net

Charlie DeTar

unread,
May 23, 2011, 9:37:55 AM5/23/11
to olwi...@googlegroups.com
You'll need some custom javascript to do this. Out of the box, there's
no special notion of "selecting" a pre-existing geometry in olwidget --
it'll have to be an action that you define.

-charlie

Reply all
Reply to author
Forward
0 new messages