See the source of the layerswitcher demo:
https://github.com/walkermatt/ol3-layerswitcher/blob/master/examples/layerswitcher.html
Your JavaScript goes in an HTML <script> tag, either just pasted between <script></script>, or even better, by referring to another file using the src attribute (as in the example):
<script src="mylayerswitcher.js" defer></script>
See: http://www.w3schools.com/tags/tag_script.asp
In this case (with a relative path), mylayerswitcher.js is in the same folder as your HTML file. You can also refer to remote JavaScript files with http:// URLs.
You also need a <script> tags for OL3 and for the component itself (the js file), so the script tags become:
<script src="ol.js" defer></script> <!-- could be http reference -->
<script src="ol3-layerswitcher.js" defer></script>
<script src="mylayerswitcher.js" defer></script>
To define the styling, reference your stylesheets with
<link rel="stylesheet" href="yourstylesheet.css"> in your HTML <head>.
Kind regards,
Ben.
On 28/12/15 06:44, epyks23 wrote:
The interactive example that Ben Caradoc-Davies posted is perfect for what
I'm looking for.
I have attached the HTML code of my map.
I am new to this and I was wondering where the javascript code goes. Do I
have to create a javascript file? And paste and play around with the code
from
https://github.com/walkermatt/ol3-layerswitcher/blob/master/examples/layerswitcher.js
<https://github.com/walkermatt/ol3-layerswitcher/blob/master/examples/layerswitcher.js>
?
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Creating-a-legend-in-Geoserver-tp5242993p5243022.html
Sent from the GeoServer - User mailing list archive at Nabble.com.
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/>
New Zealand