Ad
How To Switch Layers Using Checkbox In Openlayers 3
I'm trying to switch layers using a checkbox, but the switch from "baselayer" to "topo" doesn't work. Please help:
<body>
<div id="mapa"></div>
<nav id="layers">
<ul>
<li><input type="radio" name="layer" value="baseLayer" checked>ORTO</li>
<li><input type="radio" name="layer" value="topo"> TOPO</li>
<li><input type="radio" name="layer" value="untiled"> Warstwa</li>
</ul>
</nav>
</body>
A Fiddle is also available.
Ad
Answer
Your fiddle will not work for varius reasons.
You do not include jquery but you use it within your code
source: new ol.source.ToPo
doesnt exist. It is unknow for openlayers. Maybe it is just a typo. But I have changed it tool.source.TileWMS
.
Here is your fiddle reconstructed. It takes some time to load the images, but this has to do with your server.
Also consider to upgrade to the latest ol3 version. 3.7.0 is too old!
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad