Maplibre
Follow a camera
Maplibre
Follow a camera
Follow a camera on a Maplibre map
GeoJSON Linelayer
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Display a Solvice Map on a webpage: camera</title>
<meta content="initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport"/>
<link href="https://unpkg.com/maplibre-gl@4.1.0/dist/maplibre-gl.css" rel="stylesheet"/>
<script src="https://unpkg.com/maplibre-gl@4.1.0/dist/maplibre-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
#fly {
display: block;
position: absolute;
top: 20px;
left: 50%;
transform: translate(-50%);
width: 20%;
height: 20px;
padding: 10px;
border: none;
border-radius: 3px;
font-size: 15px;
text-align: center;
color: #fff;
background: #bdbaba;
}
</style>
</head>
<body>
<div id="map"></div>
<div id="fly">MOVE CAMERA</div>
<script>
const map = new maplibregl.Map({
container: "map",
hash: true,
center: [-122.4194, 37.7749],
zoom: 3,
style: 'https://cdn.solvice.io/styles/light.json',
});
var counter = 0;
const latlngs = [[-122.4194, 37.7749],[-121.893028, 37.335480]]
document.getElementById('fly').addEventListener('click', () => {
counter++
map.flyTo({
center: latlngs[counter % latlngs.length],
essential: true
});
});
</script>
</body>
</html>