Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
slinkp opened this issue May 25, 2011 · 6 comments
Open

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

slinkp opened this issue May 25, 2011 · 6 comments

Comments

@slinkp
Copy link
Contributor

slinkp commented May 25, 2011

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
Copy link
Contributor Author

slinkp commented Aug 5, 2011

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 added a commit to openplans/olwidget that referenced this issue Aug 5, 2011
@slinkp
Copy link
Contributor Author

slinkp commented Aug 5, 2011

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

philipn pushed a commit to philipn/olwidget that referenced this issue Aug 23, 2011
@philipn
Copy link
Contributor

philipn commented Aug 24, 2011

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
Copy link
Contributor

dyve commented Aug 24, 2011

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

philipn pushed a commit to philipn/olwidget that referenced this issue Sep 26, 2011
@philipn
Copy link
Contributor

philipn commented Sep 26, 2011

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

@slinkp
Copy link
Contributor Author

slinkp commented Dec 8, 2011

yourcelf, any thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants