2.11 Afegir comparador
Exemple
.CompareMaps(options)
See the Pen CompareMaps by unitatgeostart (@unitatgeostart) on CodePen.
Codi
<html>
<head>
<meta charset="utf-8" />
<title>Exemple mapicgc-gl-js: Afegir comparador</title>
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<script src="https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-gl.js"></script>
<link
href="https://eines.icgc.cat/recursos/mapicgc-gl-js/mapicgc-gl.css"
rel="stylesheet"
/>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
}
.map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="comparison-container">
<div id="before" class="map"></div>
<div id="after" class="map"></div>
</div>
<script>
async function initMap() {
const data = await mapicgcgl.Config.getConfigICGC();
const map1 = new mapicgcgl.Map({
container: "before",
style: data.Styles.ORTO,
center: [1.1464, 41.706],
zoom: 7.4,
maxZoom: 19,
hash: true,
pitch: 0,
});
const map2 = new mapicgcgl.Map({
container: "after",
style: data.Styles.TOPO,
center: [1.1464, 41.706],
zoom: 7.4,
maxZoom: 19,
hash: true,
pitch: 0,
});
var container = "#comparison-container";
var map = new mapicgcgl.CompareMaps(map1, map2, container, {});
}
initMap();
</script>
</body>
</html>