Skip to content

Instantly share code, notes, and snippets.

@rfriberg
Last active February 28, 2017 18:39
Show Gist options
  • Save rfriberg/fafb4be7eb1cc5007847114222af8dde to your computer and use it in GitHub Desktop.
Save rfriberg/fafb4be7eb1cc5007847114222af8dde to your computer and use it in GitHub Desktop.
Panning geology map
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lake Mead Geology Pan</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://mapzen.com/js/mapzen.css">
<script src="https://mapzen.com/js/mapzen.min.js"></script>
<style>
#map {
height: 100%;
width: 100%;
position: absolute;
}
html,body{margin: 0; padding: 0}
</style>
</head>
<body>
<div id="map"></div>
<script>
// Mapzen API key (replace key with your own)
// To generate your own key, go to https://mapzen.com/developers/
L.Mapzen.apiKey = 'mapzen-JA21Wes';
var center = [36.0,-115.3];
var map = L.Mapzen.map('map', {
center: center,
zoom: 12,
scene: 'https://mapzen.com/api/scenes/22/111/resources/default.yaml',
});
// Add attribution for NPS geology data
map.attributionControl.addAttribution('Geology data &copy; <a href="https://www.nps.gov">NPS</a>');
// Set locations for panTo. Tip: make sure they are each ~ equidistant from the last.
var locations = [[36.44,-114.15],[36.0,-114.1],[36.2,-114.2],[36.1,-114.3],[36.0,-114.4]];
for (var x = 0; x < locations.length; x++) {
var durationTime = 50; // in seconds
var loopTime = x * (durationTime * 1000); // in miliseconds
setTimeout(function(y) {
map.panTo(locations[y], {animate: true, duration: durationTime});
}, loopTime, x);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment