<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Multiple Styles</title>
<link href="https://tiles.locationiq.com/v3/libs/leaflet/1.8.0/leaflet.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="https://tiles.locationiq.com/v3/libs/leaflet/1.8.0/leaflet.js"></script>
<script type="text/javascript" src="https://tiles.locationiq.com/v3/js/liq-styles-ctrl-leaflet.js?v=0.1.8"></script>
<style type="text/css">
body {
margin: 0;
}
#map {
width: 100vw;
height: 100vh;
}
</style>
</head>
<body>
<div id="map"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol/dist/L.Control.Locate.min.css" />
<script src="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol/dist/L.Control.Locate.min.js" charset="utf-8"></script>
<script type="text/javascript">
// Maps access token goes here
var key = 'pk.aa7f5d0539c5675b7f3429402939d8fa';
// Add layers that we need to the map
var streets = L.tileLayer.Unwired({key: key, scheme: "streets"});
// Initialize the map
var map = L.map('map', {
center: [39.73, -104.99], // Map loads with this location as center
zoom: 14,
scrollWheelZoom: true,
layers: [streets],
zoomControl: false
});
// Define different layers
var dark = L.tileLayer.Unwired({ key: key, scheme: "dark" });
var light = L.tileLayer.Unwired({ key: key, scheme: "light" });
// Add the 'zoom' control
L.control.zoom({
position: 'topright'
}).addTo(map);
// Add the 'layers' control
L.control.layers({
"Streets": streets,
"Dark": dark,
"Light": light
}, null, {
position: "topright"
}).addTo(map);
// Add the 'scale' control
L.control.scale().addTo(map);
L.control.locate({
position: "bottomright"
}).addTo(map);
//fix for white lines in satellite view https://github.com/Leaflet/Leaflet/issues/3575#issuecomment-362230413
(function () {
var originalInitTile = L.GridLayer.prototype._initTile
L.GridLayer.include({
_initTile: function (tile) {
originalInitTile.call(this, tile);
var tileSize = this.getTileSize();
tile.style.width = tileSize.x + 1 + 'px';
tile.style.height = tileSize.y + 1 + 'px';
}
});
})()
</script>
</body>
</html>