Ticket #14886: geomodeladmin_format_patch.diff

File geomodeladmin_format_patch.diff, 2.0 KB (added by slinkp, 5 years ago)

this version of the patch allows passing arbitrary options to the WMS layer constructor

  • django/contrib/gis/admin/options.py

     
    3737    wms_url = 'http://labs.metacarta.com/wms/vmap0'
    3838    wms_layer = 'basic'
    3939    wms_name = 'OpenLayers WMS'
     40    wms_options = {'format': 'image/jpeg'}
    4041    debug = False
    4142    widget = OpenLayersWidget
    4243
     
    7778        class OLMap(self.widget):
    7879            template = self.map_template
    7980            geom_type = db_field.geom_type
     81            wms_options = ''
     82            if self.wms_options:
     83                wms_options = ["%s: '%s'" % pair for pair in self.wms_options.items()]
     84                wms_options = ', '.join(wms_options)
     85                wms_options = ', ' + wms_options
    8086            params = {'default_lon' : self.default_lon,
    8187                      'default_lat' : self.default_lat,
    8288                      'default_zoom' : self.default_zoom,
  • django/contrib/gis/templates/gis/admin/openlayers.js

     
    108108    // The admin map for this geometry field.
    109109    {{ module }}.map = new OpenLayers.Map('{{ id }}_map', options);
    110110    // Base Layer
    111     {{ module }}.layers.base = {% block base_layer %}new OpenLayers.Layer.WMS( "{{ wms_name }}", "{{ wms_url }}", {layers: '{{ wms_layer }}'} );{% endblock %}
     111    {{ module }}.layers.base = {% block base_layer %}new OpenLayers.Layer.WMS( "{{ wms_name }}", "{{ wms_url }}", {layers: '{{ wms_layer }}' {{ wms_options|safe }} } );{% endblock %}
    112112    {{ module }}.map.addLayer({{ module }}.layers.base);
    113113    {% block extra_layers %}{% endblock %}
    114114    {% if is_linestring %}OpenLayers.Feature.Vector.style["default"]["strokeWidth"] = 3; // Default too thin for linestrings. {% endif %}
Back to Top