Skip to content

Instantly share code, notes, and snippets.

@ThomasG77
Last active November 8, 2024 19:02
Show Gist options
  • Save ThomasG77/f3ef1ae8be9fd1d62733e32453ba0d97 to your computer and use it in GitHub Desktop.
Save ThomasG77/f3ef1ae8be9fd1d62733e32453ba0d97 to your computer and use it in GitHub Desktop.
Leaflet styling source to black&white/grayscale on client side
<<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style type="text/css">
#viewerDiv {
width:100%;
height:600px;
}
.bw {
filter: grayscale(100%) opacity(80%);
}
</style>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
</head>
<body>
<div id="viewerDiv"></div>
<script type="text/javascript">
window.onload= function() {
var map = L.map("viewerDiv").setView([48.845,2.424],10) ;
L.tileLayer(
'https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM_0_19&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2&format=image/png&style=normal',
{
minZoom : 0,
maxZoom : 18,
tileSize : 256,
attribution : "IGN-F/Géoportail",
className: "bw"
}).addTo(map);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment