Skip to content

Instantly share code, notes, and snippets.

@tmcw
Last active December 16, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmcw/5375262 to your computer and use it in GitHub Desktop.
Save tmcw/5375262 to your computer and use it in GitHub Desktop.

From MapBox v0 to v1

MapBox.js v0 is an API built on Modest Maps, while MapBox.js v1 is an API built on Leaflet. Here's how to go from one to the other.

// v0
mapbox.layer().id('foo.bar');
// v1
L.mapbox.tileLayer('foo.bar');

// v0
mapbox.markers.layer().id('foo.bar');
// v1
L.mapbox.markerLayer('foo.bar');

// v0
mapbox.map('foo');
// v1
L.mapbox.map('foo');

// v0
map.interaction.auto();
// v1
var gridLayer = L.mapbox.gridLayer('foo.bar');
var gridControl = L.mapbox.gridControl(gridLayer);
map.addLayer(gridLayer).addControl(gridControl);

// v0
map.ui.hash.add();
// v1
L.hash().addTo(map);

// v0
map.center({ lat: 0, lon: 20 }).zoom(5);
// v1
map.setView([0, 20], 5);

// v0
mapbox.layer().tilejson({});
// v1
L.mapbox.tileLayer({});

// v0
markersLayer.filter(function(f) { return f.properties.cool; });
var filter = markersLayer.filter();
// v1
markersLayer.setFilter(function(f) { return f.properties.cool; });
var filter = markersLayer.getFilter();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment