[OpenLayers-Users] How to put custom icons in layertree
Asle Benoni
asle.benoni at gmail.com
Fri Jun 15 10:14:39 PDT 2012
Hello,
I am using Openlayers 2.8, Mapfish and Geoext and have a layertree. I may
be asking on the wrong list but what is the best way to put different icons
on the layertree. I use this approach now when creating the layer:
var createWmsLayer = function(name, url, params, options) {
var layer = new OpenLayers.Layer.WMS(name, url, params, options);
map.addLayer(layer);
return layer;
};
// Then the layer:
createWmsLayer(
"<span class='cr'>Kritisk truet</span>", "
http://mydomain.com/geoserver/wms",
{layers: 'gbif_ns:kritisk_truet',format: 'image/png',
transparent: 'true'}, {singleTile: true, ratio: 1, isBaseLayer:false,
visibility: true}
);
// The css
span.cr {background: url(../images/CR.png) top left
no-repeat;padding-left:20px !important}
So now I can use a background icon on this layer in the layertree. Problem
is that the layername now is "<span class='cr'>Kritisk truet</span>" and
not so easy to refer to later. I would like the layername to be only
"Kritisk truet" but then i don't have any way to style it. Is there a
better way so I can remove all the code around the name?
Thanks for any help!
~asle benoni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120615/24ad48d4/attachment.html>
More information about the Users
mailing list