<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Dynamically Drawing a Line</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/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>
var map = L.mapbox.map('map', 'examples.map-9ijuk24y')
.setView([0, 0], 3);
// add a new line to the map, but one with no points - yet
var polyline = L.polyline([]).addTo(map);
// keep a tally of how many points we've added to the map
var pointsAdded = 0;
// start adding new points to the map
add();
function add() {
// addLatLng takes a new latLng location and puts it at the end of the
// line. You could pull points from your data or generate them - this
// example just makes a sine wave with some math.
polyline.addLatLng(
L.latLng(
Math.cos(pointsAdded / 20) * 30,
pointsAdded));
// pan the map along with where the line is being added. optional, of course
map.setView([0, pointsAdded], 3);
// then, if we haven't already added a lot of points, queue up the page
// to call add() in a 100 milliseconds
if (++pointsAdded < 360) window.setTimeout(add, 100);
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Markers As Links</title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/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>
var map = L.mapbox.map('map', 'examples.map-20v6611k').setView([39.12367, -76.81229], 9);
// The GeoJSON representing the two point features
var geoJson = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
properties: {
title: 'Washington, D.C.',
'marker-color': '#f00',
'marker-size': 'large',
url: 'http://en.wikipedia.org/wiki/Washington,_D.C.'
},
geometry: {
type: 'Point',
coordinates: [-77.03201, 38.90065]
}
},
{
type: 'Feature',
properties: {
title: 'Baltimore, MD',
'marker-color': '#f00',
'marker-size': 'large',
url: 'http://en.wikipedia.org/wiki/Baltimore'
},
geometry: {
type: 'Point',
coordinates: [-76.60767, 39.28755]
}
}]
};
// Pass features and a custom factory function to the map
map.featureLayer.setGeoJSON(geoJson);
map.featureLayer.on('click', function(e) {
e.layer.unbindPopup();
window.open(e.layer.feature.properties.url);
});
</script>
</body>
</html>