Created
December 20, 2012 00:17
-
-
Save tmcw/4341968 to your computer and use it in GitHub Desktop.
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> | |
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js'></script> | |
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.css' rel='stylesheet' /> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position:absolute; top:0; bottom:0; width:100%; } | |
</style> | |
</head> | |
<body> | |
<div id='map'></div> | |
<script> | |
// If you're creating a new interactive layer, follow the tooltips docs: | |
// http://mapbox.com/tilemill/docs/crashcourse/tooltips/ | |
mapbox.load('examples.map-z2effxa8', function(o) { | |
var map = mapbox.map('map'); | |
map.addLayer(o.layer).zoom(3).center({ lat: 48, lon: -100 }); | |
map.interaction.auto(); | |
// Attribute map | |
map.ui.attribution.add() | |
.content('<a href="http://mapbox.com/about/maps">Terms & Feedback</a>'); | |
var markers = mapbox.markers.layer(); | |
map.addLayer(markers); | |
mapbox.markers.interaction(markers); | |
function setUserLocationMarker(lon, lat) { | |
markers.add_feature({ | |
geometry: { | |
coordinates: [lon, lat] | |
}, | |
properties: { | |
'marker-color': '#000', | |
'marker-symbol': 'star', | |
title: 'You are here :)' //[lonVal, latVal].join(',') | |
} | |
}); | |
} | |
function addNewMarker(lon, lat, title) { | |
markers.add_feature({ | |
geometry: { | |
coordinates: [lon, lat] | |
}, | |
properties: { | |
'marker-color': '#000', | |
'marker-symbol': 'star', | |
title: title | |
} | |
}); | |
} | |
setUserLocationMarker(-100, 48); | |
addNewMarker(-101, 54, 'foo'); | |
addNewMarker(-102, 42, 'bar'); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment