I am displaying a leaflet base map. I am using an HTML5 slider to set the opacity to a layergroup but it is not working.
I was wondering what I'm doing wrong.
Thanks in advance!
<h3>TF.Landscape</h3>
<br><input type="button" value=" + " onclick="BaseMapAsLayerGroup('http://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png')">
<br><input id="slide" type="range" min="0" max="1" step="0.1" value="0" onchange="updateOpacity(this.value)">
<hr>
<div id="map" style="width: 800px; height: 600px"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"> </script>
<script>
var map;
var capa;
function BaseMapAsLayerGroup(url){
if(!map) {
map = L.map('map').setView([-41.2858, 174.78682], 14);
}
capa = new L.LayerGroup();
L.tileLayer(url, {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a>',
maxZoom: 18
}).addTo(capa);
map.addLayer(capa);
}
function updateOpacity(value) {
capa.opacity(value);
}
</script>