-
-
Save cassioeskelsen/2400975 to your computer and use it in GitHub Desktop.
Wax interactivity with location interaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Wax Interactivity</title> | |
</head> | |
<body> | |
<style> | |
#map { | |
width: 100%; | |
height: 360px; | |
} | |
.wax-tooltip { | |
z-index:999999; | |
position:absolute; | |
background:#333; | |
color:#fff; | |
padding:10px; | |
-webkit-user-select:auto; | |
left:10px; | |
top:10px; | |
max-width:300px; | |
opacity:1; | |
-webkit-transition:opacity 150ms; | |
-moz-transition:opacity 150ms; | |
} | |
.wax-fade { opacity:0; } | |
</style> | |
<div id='map'></div> | |
<script src='https://raw.github.com/mapbox/wax/master/ext/modestmaps.min.js'></script> | |
<script src='https://raw.github.com/mapbox/wax/master/dist/wax.mm.min.js'></script> | |
<script> | |
var url = 'http://api.tiles.mapbox.com/v3/tristen.cdi-base-layer.jsonp'; | |
wax.tilejson(url, function(tilejson) { | |
var map = new MM.Map('map', new wax.mm.connector(tilejson)); | |
wax.mm.interaction() | |
.map(m) | |
.tilejson(tilejson) | |
.on(wax.tooltip().parent($('.header')[0]).events()) | |
.on('on', function(o) { | |
if (o.e.type && o.e.type !== 'mousemove') { | |
var loc = o.formatter({ format: 'location' }, o.data); | |
if (loc) window.location = loc; | |
} | |
}); | |
m.setZoomRange(4, 7); | |
m.setCenterZoom({ lat: 37.61, lon: 268.068 }, 4); | |
} | |
); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment