Skip to content

Instantly share code, notes, and snippets.

@yhahn
Created December 10, 2012 15:21
Show Gist options
  • Save yhahn/4251201 to your computer and use it in GitHub Desktop.
Save yhahn/4251201 to your computer and use it in GitHub Desktop.
Pointselector example
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v0.6.6/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>
mapbox.auto('map', 'examples.map-z2effxa8', function(map) {
map.ui.pointselector.addCallback('change', function(drawn, locations) {
locations = map.ui.pointselector.locations();
var last = locations.length - 1;
var la = locations[last].lat;
var lo = locations[last].lon;
for (var i = 0; i < last; i++) {
map.ui.pointselector.deleteLocation(locations[i]);
}
});
map.ui.pointselector.add();
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment