class MyInfoModelForm(MapModelForm): start = MapField([ EditableLayerField({'name': 'start'}), InfoLayerField([[Point(0, 0, srid=4326), "Of interest"]]), ]) class Meta: model = MyModel
class TestAdminForm(forms.ModelForm): boundary = MapField([ EditableLayerField({'geometry': 'polygon', 'name': 'boundary', 'is_collection': True}), InfoLayerField([["SRID=4326;POINT (0 0)", "Of Interest"]], {"name": "Test"}), ], { 'overlay_style': { 'fill_color': '#00ff00' }}, template="olwidget/admin_olwidget.html") def clean(self): self.cleaned_data['boundary'] = self.cleaned_data['boundary'][0] return self.cleaned_data class Meta: model = Country
class MixedForm(forms.Form): capitals = MapField([ InfoLayerField([[c.boundary, c.about] for c in Country.objects.all()], { 'overlay_style': { 'fill_opacity': 0, 'stroke_color': "white", 'stroke_width': 6, }, 'name': "Country boundaries", }), EditableLayerField({ 'geometry': 'point', 'name': "Country capitals", 'is_collection': True, }), ], {'layers': ['google.satellite']})
class MyMultiForm(forms.Form): mymap = MapField(( EditableLayerField({'name': 'Fun'}), InfoLayerField([[Point(0, 0, srid=4326), "that"]]), EditableLayerField(), ))
class MixedForm(forms.Form): stuff = MapField([ InfoLayerField([["SRID=4326;POINT(0 0)", "Origin"]]), EditableLayerField({'geometry': 'point'}), ])