Skip to content

Instantly share code, notes, and snippets.

@tristen
Last active October 5, 2015 07:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tristen/2771269 to your computer and use it in GitHub Desktop.
Save tristen/2771269 to your computer and use it in GitHub Desktop.
Hash

Hash

Best to download this example to see the full effect outside of an iframe. Explore the anchor links in the example above. The hash links are refresh the map to the exact coordinates described.

Contributors

var initMap = function() {
var provider = new MM.TemplatedLayer("http://acetate.geoiq.com/tiles/acetate/{Z}/{X}/{Y}.png");
var map = new MM.Map("map", provider);
map.setCenterZoom(new MM.Location(37.804, -122.252), 12);
var hash = new MM.Hash(map);
}
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Modest Maps JS Demo | Great Circle</title>
<link rel='stylesheet' href='style.css'>
</head>
<body onload='initMap()'>
<div id='controls'>
<ul>
<li><a href="#17/37.7647404/-122.4195235">Stamen</a></li>
<li><a href="#18/0/0">null island</a></li>
</ul>
</div>
<div id='map'></div>
<script src='https://rawgithub.com/stamen/modestmaps-js/master/modestmaps.min.js'></script>
<script src='app.js'></script>
</body>
</html>
body {
font: 13px/22px 'Helvetica Neue', Helvetica, sans;
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0; left: 0;
width: 100%;
height: 100%;
}
a {
text-decoration: none;
color: #1a73c7;
font-weight: bold;
display: block;
padding: 0 5px 2px;
}
a:hover {
background-color: #1a73c7;
color: #fff;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
#controls {
background: #fff;
border: 1px solid #666;
padding: 5px;
z-index: 1000;
position: absolute;
top: 10px; left: 10px;
width: 98px;
box-shadow: 0 1px 8px rgba(0,0,0,0.3);
-moz-box-shadow: 0 1px 8px rgba(0,0,0,0.3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment