Linking to external data

Hover over countries to view data in interactivity along with data from an external source.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Linking to external data</title>
  <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
  <script src='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.js'></script>
  <link href='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.css' rel='stylesheet' />
  <!--[if lte IE 8]>
    <link href='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.ie.css' rel='stylesheet'>
  <![endif]-->
  <style>
    body { margin:0; padding:0; }
    #map { position:absolute; top:0; bottom:0; width:100%; }
  </style>
</head>
<body>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
#currency {
  z-index:9999;
  position:absolute;
  bottom:10px;
  left:10px;
  font-size:36px;
  font-weight:bold;
  }
</style>
<div id='currency'></div>
<div id='map'></div>
<script>
var map = L.mapbox.map('map', 'examples.map-zmy97flj');

// This is example 'external data'. It's obviously very much an example,
// and in practice you'll want to use jQuery's .ajax to pull in data or
// you already have it in some other form. The important part is that
// this data has a key, like 'Canada', which exactly matches part of the
// data in the tileset - here it's that the key is the same as o.data.admin
var currencies = {
    'United States of America': 'USD',
    'Canada': 'CAD',
    'Mexico': 'MXN'
};

var currency = document.getElementById('currency');

// This tileset, Geography Class, has interactivity defined in TileMill
// and displayed in its tooltips. If you're creating a new tileset to use
// with this technique, see the documentation on defining tooltips:
// > http://mapbox.com/tilemill/docs/crashcourse/tooltips/
// and you'll need to use fields for them to be available here -
// to hide them in tooltips but use them here, you can use something like
//
//   <span style='display:none'>}</span>
//
// in the tooltip content to get TileMill to detect that the field }
// should be available in interaction.
map.gridLayer
    .on('mousemove',function(o) {
        document.getElementById('currency').innerHTML = (o.data && currencies[o.data.admin]) || '';
    }).on('mouseout', function(o) {
        document.getElementById('currency').innerHTML = '';
    });
</script>
The code and documentation to mapbox.js is hosted on GitHub where you can contribute changes and improvements.