Video embeds in tooltips

Embedding iframe videos in feature tooltips

<!DOCTYPE html>
<meta charset=utf-8 />
<title>Video embeds in tooltips</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%; }
    .leaflet-popup-content-wrapper { width: 400px;}

<div id='map'></div>

L.mapbox.accessToken = '<your access token here>';
var map ='map')
    .setView([0,0], 5)

// The GeoJSON representing a point feature with a property of 'video' for the Vimeo iframe
var geoJson = {
    features: [{
        type: 'Feature',
        properties: {
            'marker-color': '#f00',
            'marker-size': 'large',
            'marker-symbol': 'rocket',
            video: '<iframe src="//" width="380" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href=""><h2>How Simplicity Will Save GIS</h2><p>Vladimir Agafonkin</a> from <a href="">FOSS4G</a> on <a href="">Vimeo</a>.</p>',
        geometry: {
            type: 'Point',
            coordinates: [0,0]

var myLayer = L.mapbox.featureLayer().addTo(map);

// Add the iframe in a marker tooltip using the custom feature properties
myLayer.on('layeradd', function(e) {
    var marker = e.layer,
        feature = marker.feature;

    // Create custom popup content from the GeoJSON property 'video'
    var popupContent =;

    // bind the popup to the marker
        closeButton: false,
        minWidth: 320

// Add features to the map

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