Commit 5585a2a7 authored by Alex Kerney's avatar Alex Kerney

Passing 'data-widths' and 'data-height' to the Leaflet view if the keys are in `form_widget_args`

parent 6e333212
......@@ -61,7 +61,8 @@ class GeoJSONField(JSONField):
def process_formdata(self, valuelist):
super(GeoJSONField, self).process_formdata(valuelist)
print type(self.data)
if str(self.data) is '':
self.data = None
if type(self.data) is not NoneType:
web_shape = self.session.scalar(func.ST_AsText(func.ST_Transform(func.ST_GeomFromText(shape(self.data).wkt, self.web_srid), self.transform_srid)))
self.data = 'SRID='+str(self.srid)+';'+str(web_shape)
......@@ -36,9 +36,10 @@ class LeafletWidget(TextArea):
kwargs.setdefault('data-geometry-type', gtype)
# set optional values from constructor
if self.width:
print kwargs
if not kwargs.has_key("data-width"):
kwargs["data-width"] = self.width
if self.height:
if not kwargs.has_key("data-height"):
kwargs["data-height"] = self.height
if self.center:
kwargs["data-lat"] = lat(self.center)
......@@ -67,4 +68,5 @@ class LeafletWidget(TextArea):
kwargs["data-max-bounds-ne-lat"] = maxx
kwargs["data-max-bounds-ne-lng"] = maxy
print kwargs
return super(LeafletWidget, self).__call__(field, **kwargs)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment