Leaflet Label
Custom tooltips on hover with the Leaflet Label plugin.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Leaflet Label</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.js'></script>
<link href='https://api.mapbox.com/mapbox.js/v3.1.1/mapbox.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.js'></script>
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-label/v0.2.1/leaflet.label.css' rel='stylesheet' />
<div id='map'></div>
<script>
L.mapbox.accessToken = '<your access token here>';
var map = L.mapbox.map('map', 'mapbox.streets', {
center: [38.91557, -77.03198],
zoom: 16
});
L.marker([38.9206, -77.0357]).bindLabel('Meridian Hill Park').addTo(map);
L.marker([38.909776, -77.034097]).bindLabel('Sweetgreen').addTo(map);
L.marker([38.917139, -77.031745]).bindLabel('Subway').addTo(map);
L.marker([38.915300, -77.031724]).bindLabel('Manny & Olga\'s Pizza').addTo(map);
L.marker([38.913388, -77.032351]).bindLabel('Crossfit DC').addTo(map);
L.marker([38.91371, -77.03590]).bindLabel('House of the Temple').addTo(map);
L.marker([38.914722, -77.034414]).bindLabel('St James Church').addTo(map);
L.marker([38.91680, -77.02889]).bindLabel('U Street Metro').addTo(map);
L.marker([38.914271, -77.028293]).bindLabel('The Coffee Bar').addTo(map);
</script>
Get a free Mapbox account to create your own custom map and use it in this example.
Use this example by copying its source into your own HTML page and
replacing the Map ID
with
one of your own from your projects.
Having trouble with JavaScript? Try out Codecademy
or contact our support team.