[OpenLayers-Users] adding copyright text

Andreas Hocevar ahocevar at opengeo.org
Thu Jun 30 10:55:31 EDT 2011


Hi,

the OpenLayers.Layer.WMS constructor takes, 4 arguments:

OpenLayers.Layer.WMS(name, url, params, options)

The params are for everything that gets appended to the GetMap
reqeusts for the images. The options are for everything that
configures the OpenLayers.Layer.WMS object. The attribution property
goes into the options (4th argument).

If configured like this, there is no need to add the Attribution
control, because it is one of the default controls (unless your build
profile does not contain it, or you configure your map with a custom
controls array).

I just updated the Layer.WMS docs to make this a bit more clear. See
http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/WMS-js.html#OpenLayers.Layer.WMS.OpenLayers.Layer.WMS

Hope this helps.
Andreas.

On Thu, Jun 30, 2011 at 11:50 AM, Gary Nobles <garynobles at yahoo.com> wrote:
> Hi list, me again, I can never seem to get these things to work by looking at
> the examples
>
>
> I have a layer
> provincie_04 = new OpenLayers.Layer.WMS("Provinces",
> "http://domain/geoserver/wms", {layers:"provincie_04"},options);
>
> I want to add a copyright statement so I add {'attribution': 'Provided by
> Gary'}
>
> If I add this after the options variable I get the text but no map, if its
> before the options I get the map but no attribution
>
> I also add the:   map.addControl(new OpenLayers.Control.Attribution());
>
> full (ish) code:
>
> var map;
> var options;
>
>
> function init(){
>    var bounds = new OpenLayers.Bounds(
>        14000, 305900,
>        277000, 610500
>        );
>                //WSEN
>    var options = {
>        controls: [],
>        maxExtent: bounds,
>        maxResolution: 1219.2140625,
>        projection: "EPSG:28992",
>        units: 'm'
>        };
>
>    map = new OpenLayers.Map('map', {controls: [
>        new OpenLayers.Control.Navigation(),
>        new OpenLayers.Control.ArgParser(),
>        new OpenLayers.Control.Attribution(),
>        new OpenLayers.Control.OverviewMap()
>        ]
>        });
>
> provincie_04 = new OpenLayers.Layer.WMS("Provinces",
> "http://domain/geoserver/wms", {layers:"provincie_04"},options);
>
> map.addLayer(provincie_04);
>
>
>
> map.addControl(new OpenLayers.Control.Attribution());
> }
>
> --
> View this message in context: http://osgeo-org.1803224.n2.nabble.com/adding-copyright-text-tp6532522p6532522.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list