olwidget icon indicating copy to clipboard operation
olwidget copied to clipboard

Feature request: custom WMS layers for django-olwidget

Open slinkp opened this issue 13 years ago • 6 comments

Much like #47 ... I'd like to be able to add any WMS server as a base layer option, via some array or something in settings.py.

If the wms server didn't need any extra options, one expedient hack might be to interpret unknown types as URLs, eg. do this in olwidget.js at the end of the wms function: {{{ ... } else if (type === "blank") { return new OpenLayers.Layer("", {isBaseLayer: true}); } else { return new OpenLayers.Layer.WMS("custom WMS server", type); } }}}

but this is pretty obviously lame: you're going to need to pass options somehow. I have one possibly better idea to pursue, will check it out.

slinkp avatar May 25 '11 17:05 slinkp

Okay, I've added a 'custom.foo' constructor. This gist shows how it works, with an example in the docs - though rather than applying this to my olwidget fork, so far I'm applying this as a monkeypatch in my own javascript. https://gist.github.com/1128539

slinkp avatar Aug 05 '11 21:08 slinkp

On second thought, I pushed it to my fork as the custom_base_layers branch.

slinkp avatar Aug 05 '11 21:08 slinkp

We need this functionality too.

I think the ideal way to do this would be to have, in settings.py:

OLWIDGET_CUSTOM_BASE_LAYERS = {
    'opengeo_osm':  # to use this, your olwidget layers would include ['custom.opengeo_osm']
        {"class": "WMS",  # The OpenLayers.Layer subclass to use.
         "args": [  # These are passed as arguments to the constructor.
            "OpenStreetMap (OpenGeo)",
            "http://maps.opengeo.org/geowebcache/service/wms",
            {"layers": "openstreetmap",
             "format": "image/png",
             "bgcolor": "#A1BDC4",
             },
            {"wrapDateLine": True
             },
            ],
         }
}

rather than declare this explicitly in JS-land. Then in JS we can allow olwidget.registerCustomBaseLayers() which acts in much the same way.

I've added this to my fork's custom_base_layers_fixed branch. I'll issue a pull request after we've played with it in production for a bit.

philipn avatar Aug 24 '11 00:08 philipn

Interested to see how this plays out, could be major win for one of my current projects too. Please keep us posted.

dyve avatar Aug 24 '11 06:08 dyve

I've issued a pull request after using this in production for a few weeks.

philipn avatar Sep 26 '11 04:09 philipn

yourcelf, any thoughts on this?

slinkp avatar Dec 08 '11 21:12 slinkp