Disable map rotation
Prevent users from rotating a map.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Disable map rotation</title>
<meta property="og:description" content="Prevent users from rotating a map." />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/trackasia-gl.css" />
<script src="https://unpkg.com/[email protected]/dist/trackasia-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new trackasiagl.Map({
container: 'map', // container id
style: 'https://maps.track-asia.com/styles/v2/streets.json?key=public_key', //stylesheet location
center: {"lat":10.762622,"lng":106.660172}, // starting position
zoom: 6 // starting zoom
});
// disable map rotation using right click + drag
map.dragRotate.disable();
// disable map rotation using keyboard
map.keyboard.disable();
// disable map rotation using touch rotation gesture
map.touchZoomRotate.disableRotation();
</script>
</body>
</html>