yourcelf / olwidget

Javascript library to replace textareas that contain WKT data with editable OpenLayers maps, and a django app using it for django forms and admin.
Other
91 stars 44 forks source link

Feature request: custom WMS layers for django-olwidget #60

Open slinkp opened 13 years ago

slinkp commented 13 years ago

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 commented 13 years ago

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 commented 13 years ago

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

philipn commented 13 years ago

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.

dyve commented 13 years ago

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

philipn commented 12 years ago

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

slinkp commented 12 years ago

yourcelf, any thoughts on this?