29
29
layerswitcher = True
31
admin_media_prefix = settings.ADMIN_MEDIA_PREFIX
35
34
map_template = 'gis/admin/openlayers.html'
36
openlayers_url = 'http://openlayers.org/api/2.6/OpenLayers.js'
35
openlayers_url = 'http://openlayers.org/api/2.8/OpenLayers.js'
36
point_zoom = num_zoom - 6
37
37
wms_url = 'http://labs.metacarta.com/wms/vmap0'
38
38
wms_layer = 'basic'
39
39
wms_name = 'OpenLayers WMS'
54
54
for viewing/editing GeometryFields.
56
56
if isinstance(db_field, models.GeometryField):
57
request = kwargs.pop('request', None)
57
58
# Setting the widget with the newly defined widget.
58
59
kwargs['widget'] = self.get_map_widget(db_field)
59
60
return db_field.formfield(**kwargs)
66
67
in the `widget` attribute) using the settings from the attributes set
69
is_collection = db_field._geom in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
70
is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION')
71
if db_field._geom == 'GEOMETRYCOLLECTION': collection_type = 'Any'
72
else: collection_type = OGRGeomType(db_field._geom.replace('MULTI', ''))
72
if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any'
73
else: collection_type = OGRGeomType(db_field.geom_type.replace('MULTI', ''))
74
75
collection_type = 'None'
76
77
class OLMap(self.widget):
77
78
template = self.map_template
78
geom_type = db_field._geom
79
params = {'admin_media_prefix' : self.admin_media_prefix,
80
'default_lon' : self.default_lon,
79
geom_type = db_field.geom_type
80
params = {'default_lon' : self.default_lon,
81
81
'default_lat' : self.default_lat,
82
82
'default_zoom' : self.default_zoom,
83
83
'display_wkt' : self.debug or self.display_wkt,
84
'geom_type' : OGRGeomType(db_field._geom),
84
'geom_type' : OGRGeomType(db_field.geom_type),
85
85
'field_name' : db_field.name,
86
86
'is_collection' : is_collection,
87
87
'scrollable' : self.scrollable,
88
88
'layerswitcher' : self.layerswitcher,
89
89
'collection_type' : collection_type,
90
'is_linestring' : db_field._geom in ('LINESTRING', 'MULTILINESTRING'),
91
'is_polygon' : db_field._geom in ('POLYGON', 'MULTIPOLYGON'),
92
'is_point' : db_field._geom in ('POINT', 'MULTIPOINT'),
90
'is_linestring' : db_field.geom_type in ('LINESTRING', 'MULTILINESTRING'),
91
'is_polygon' : db_field.geom_type in ('POLYGON', 'MULTIPOLYGON'),
92
'is_point' : db_field.geom_type in ('POINT', 'MULTIPOINT'),
93
93
'num_zoom' : self.num_zoom,
94
94
'max_zoom' : self.max_zoom,
95
95
'min_zoom' : self.min_zoom,
101
101
'scale_text' : self.scale_text,
102
102
'map_width' : self.map_width,
103
103
'map_height' : self.map_height,
104
'point_zoom' : self.point_zoom,
104
105
'srid' : self.map_srid,
105
106
'display_srid' : self.display_srid,
106
107
'wms_url' : self.wms_url,