equal
deleted
inserted
replaced
62 return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) |
62 return super(GeoModelAdmin, self).formfield_for_dbfield(db_field, **kwargs) |
63 |
63 |
64 def get_map_widget(self, db_field): |
64 def get_map_widget(self, db_field): |
65 """ |
65 """ |
66 Returns a subclass of the OpenLayersWidget (or whatever was specified |
66 Returns a subclass of the OpenLayersWidget (or whatever was specified |
67 in the `widget` attribute) using the settings from the attributes set |
67 in the `widget` attribute) using the settings from the attributes set |
68 in this class. |
68 in this class. |
69 """ |
69 """ |
70 is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION') |
70 is_collection = db_field.geom_type in ('MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON', 'GEOMETRYCOLLECTION') |
71 if is_collection: |
71 if is_collection: |
72 if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any' |
72 if db_field.geom_type == 'GEOMETRYCOLLECTION': collection_type = 'Any' |
109 'wms_name' : self.wms_name, |
109 'wms_name' : self.wms_name, |
110 'debug' : self.debug, |
110 'debug' : self.debug, |
111 } |
111 } |
112 return OLMap |
112 return OLMap |
113 |
113 |
114 # Using the Beta OSM in the admin requires the following: |
|
115 # (1) The Google Maps Mercator projection needs to be added |
|
116 # to your `spatial_ref_sys` table. You'll need at least GDAL 1.5: |
|
117 # >>> from django.contrib.gis.gdal import SpatialReference |
|
118 # >>> from django.contrib.gis.utils import add_postgis_srs |
|
119 # >>> add_postgis_srs(SpatialReference(900913)) # Adding the Google Projection |
|
120 from django.contrib.gis import gdal |
114 from django.contrib.gis import gdal |
121 if gdal.HAS_GDAL: |
115 if gdal.HAS_GDAL: |
122 class OSMGeoAdmin(GeoModelAdmin): |
116 class OSMGeoAdmin(GeoModelAdmin): |
123 map_template = 'gis/admin/osm.html' |
117 map_template = 'gis/admin/osm.html' |
124 extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js'] |
118 extra_js = ['http://openstreetmap.org/openlayers/OpenStreetMap.js'] |