diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py
index 4732e73..42e5f53 100644
a
|
b
|
class GeoModelAdmin(ModelAdmin):
|
36 | 36 | wms_url = 'http://labs.metacarta.com/wms/vmap0' |
37 | 37 | wms_layer = 'basic' |
38 | 38 | wms_name = 'OpenLayers WMS' |
| 39 | wms_options = {'format': 'image/jpeg'} |
39 | 40 | debug = False |
40 | 41 | widget = OpenLayersWidget |
41 | 42 | |
… |
… |
class GeoModelAdmin(ModelAdmin):
|
76 | 77 | class OLMap(self.widget): |
77 | 78 | template = self.map_template |
78 | 79 | geom_type = db_field.geom_type |
| 80 | |
| 81 | wms_options = '' |
| 82 | if self.wms_options: |
| 83 | wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()] |
| 84 | wms_options = ', %s' % ', '.join(wms_options) |
| 85 | |
79 | 86 | params = {'default_lon' : self.default_lon, |
80 | 87 | 'default_lat' : self.default_lat, |
81 | 88 | 'default_zoom' : self.default_zoom, |
… |
… |
class GeoModelAdmin(ModelAdmin):
|
106 | 113 | 'wms_url' : self.wms_url, |
107 | 114 | 'wms_layer' : self.wms_layer, |
108 | 115 | 'wms_name' : self.wms_name, |
| 116 | 'wms_options' : wms_options, |
109 | 117 | 'debug' : self.debug, |
110 | 118 | } |
111 | 119 | return OLMap |
diff --git a/django/contrib/gis/templates/gis/admin/openlayers.js b/django/contrib/gis/templates/gis/admin/openlayers.js
index 4f34b6b..102adfb 100644
a
|
b
|
OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
111 | 111 | // The admin map for this geometry field. |
112 | 112 | {{ module }}.map = new OpenLayers.Map('{{ id }}_map', options); |
113 | 113 | // Base Layer |
114 | | {{ module }}.layers.base = {% block base_layer %}new OpenLayers.Layer.WMS( "{{ wms_name }}", "{{ wms_url }}", {layers: '{{ wms_layer }}'} );{% endblock %} |
| 114 | {{ module }}.layers.base = {% block base_layer %}new OpenLayers.Layer.WMS("{{ wms_name }}", "{{ wms_url }}", {layers: '{{ wms_layer }}'{{ wms_options|safe }}});{% endblock %} |
115 | 115 | {{ module }}.map.addLayer({{ module }}.layers.base); |
116 | 116 | {% block extra_layers %}{% endblock %} |
117 | 117 | {% if is_linestring %}OpenLayers.Feature.Vector.style["default"]["strokeWidth"] = 3; // Default too thin for linestrings. {% endif %} |
diff --git a/django/contrib/gis/tests/geoadmin/tests.py b/django/contrib/gis/tests/geoadmin/tests.py
index aa07c2c..1f104b2 100644
a
|
b
|
from __future__ import absolute_import
|
2 | 2 | |
3 | 3 | from django.test import TestCase |
4 | 4 | from django.contrib.gis import admin |
| 5 | from django.contrib.gis.geos import Point |
5 | 6 | |
6 | 7 | from .models import City |
7 | 8 | |
… |
… |
class GeoAdminTest(TestCase):
|
14 | 15 | admin_js = geoadmin.media.render_js() |
15 | 16 | self.assertTrue(any([geoadmin.openlayers_url in js for js in admin_js])) |
16 | 17 | |
| 18 | def test_olmap_OSM_rendering(self): |
| 19 | geoadmin = admin.site._registry[City] |
| 20 | result = geoadmin.get_map_widget(City._meta.get_field('point'))( |
| 21 | ).render('point', Point(-79.460734, 40.18476)) |
| 22 | self.assertIn( |
| 23 | """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""", |
| 24 | result) |
| 25 | |
| 26 | def test_olmap_WMS_rendering(self): |
| 27 | admin.site.unregister(City) |
| 28 | admin.site.register(City, admin.GeoModelAdmin) |
| 29 | |
| 30 | geoadmin = admin.site._registry[City] |
| 31 | result = geoadmin.get_map_widget(City._meta.get_field('point'))( |
| 32 | ).render('point', Point(-79.460734, 40.18476)) |
| 33 | self.assertIn( |
| 34 | """geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {layers: \'basic\', format: 'image/jpeg'});""", |
| 35 | result) |