I am trying to add the following Leaflet.js slider to my map: https://github.com/Eclipse1979/leaflet-slider
I originally just installed leaflet when installing Carto
<!-- cartodb.js comes with Leaflet @0.7 and jQuery -->
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.15/themes/css/cartodb.css" />
However when I try to install a later version of Leaflet to user the Slider, the following type error is raised:
TypeError: L.StamenTileLayer is not a constructor
I have tried installing Leaflet using the quick start guide:
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
and by installing the filed directly from the plugin master
<link rel="stylesheet" href="leaflet.css">
<link rel="stylesheet" href="example.css">
<link rel="stylesheet" href="leaflet-slider.css">
<script src="leaflet.js"></script>
<script src="leaflet-slider.js"></script>
Both cases result in the same error. I used the following to load my Stamen layer:
var map = L.map('map').setView([51.47, 0.25], 10);
map.on('click', onMapClick);
//create a tile layer for our toner basemap
var tonerLayer = new L.StamenTileLayer("toner");
map.addLayer(tonerLayer);
I used the following code to add the spinner:
slider = L.control.slider(function(value) {
console.log(value);
}, {
min: 1000,
max: 5000,
value: 1000,
step:100,
size: '250px',
orientation:'horizontal',
id: 'slider'
}).addTo(map);