epyks23,

in Firefox and Chrome you can toggle developer tools with F12.

I looked at your Tile.html:

(1) Where is ol.control.LayerSwitcher defined? You do not have a script tag to load the definition from ol3-layerswitcher.js.

(2) You are also missing ol3-layerswitcher.css which defines the appearance and CSS hover behaviour of the layer switcher component.

(3) Your example does not resemble the ol3-layerswitcher example, which places all layers in groups and all layers and groups have a title property. The documentation and source of ol3-layerswitcher.js suggests that only layers with titles are recognised by the layer switcher.

I have attached a modified version of your Tile.html with:

- a script tag to load ol3-layerswitcher.js (same folder as the html)

- a stylesheet for ol3-layerswitcher.css (same folder as the html)

- 'title' property on all layers

- topp:states from Boundless demo WMS to have a working example, and an adjustment in the view to match

The attached html works for me with the OSM base layer and topp:states displayed and a working layer switcher at the top left.

Kind regards,
Ben.

On 05/01/16 12:51, epyks23 wrote:
Thanks for the feedback. (I am going to try and find the JavaScript console).

I can finally see the layers now  Tile.html
<http://osgeo-org.1560.x6.nabble.com/file/n5243699/Tile.html>

Now I need to add a legend so that the user can switch the layers on and
off.

I was following this example:
https://github.com/walkermatt/ol3-layerswitcher/blob/master/examples/layerswitcher.js
<https://github.com/walkermatt/ol3-layerswitcher/blob/master/examples/layerswitcher.js>

And I added the following code because I think this is the legend part. But
it does not show up on the map:

     var layerSwitcher = new ol.control.LayerSwitcher({
     tipLabel: 'Légende' // Optional label for button
     });
     map.addControl(layerSwitcher);



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/layerswitcher-js-and-adding-vector-data-from-Geoserver-tp5243249p5243699.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users


--
Ben Caradoc-Davies <[email protected]>
Director
Transient Software Limited <http://transient.nz/>
New Zealand
Title: Tiled WMS
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to