Custom tooltip

Define custom HTML for popups from marker properties.

<!DOCTYPE html>
<meta charset=utf-8 />
<title>Custom tooltip</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src=''></script>
<link href='' rel='stylesheet' />
  body { margin:0; padding:0; }
  #map { position:absolute; top:0; bottom:0; width:100%; }
<div id='map'></div>

L.mapbox.accessToken = '<your access token here>';
var map ='map', 'mapbox.streets')
    .setView([49.16326, -123.89187], 17);

var featureLayer = L.mapbox.featureLayer({
        type: 'FeatureCollection',
        features: [{
            type: 'Feature',
            properties: {
                'from': 'Duke Point',
                'to': 'Tsawwassen',
                'marker-color': '#548cba',
                'marker-size': 'large',
                'marker-symbol': 'ferry'
            geometry: {
                type: 'Point',
                coordinates: [-123.89128804206847, 49.16351524490678]

// Note that calling `.eachLayer` here depends on setting GeoJSON _directly_
// above. If you're loading GeoJSON asynchronously, like from CSV or from a file,
// you will need to do this within a `featureLayer.on('ready'` event.
featureLayer.eachLayer(function(layer) {

    // here you call `bindPopup` with a string of HTML you create - the feature
    // properties declared above are available under ``
    var content = '<h2>A ferry ride!<\/h2>' +
        '<p>From: ' + + '<br \/>' +
        'to: ' + + '<\/p>';
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.
Copy example