Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
Upgrading from Mapbox.js v1
In a few cases, you may need to make changes to code written for Mapbox.js 1.x versions in order to work with Mapbox.js 2.x.
Mapbox.js 2.x uses version 4 of the Mapbox web services API, which requires API access tokens. You must supply an access token to Mapbox.js; see API access tokens for details.
The
markerLayer
alias has been removed fromL.mapbox.map
. UsefeatureLayer
instead. For example, replacemap.markerLayer.setFilter(function(f) { ... });
with
map.featureLayer.setFilter(function(f) { ... });
L.mapbox.geocoder
andL.mapbox.geocoderControl
no longer accept arbitrary map IDs. Instead you must provide a predefined geocoder index ID (or the ID of a custom geocoder index). For instance, replaceL.mapbox.geocoderControl('examples.map-i86nkdio').addTo(map);
with
L.mapbox.geocoderControl('mapbox.places-v1').addTo(map);
See the geocoding API documentation for a complete list of predefined geocoding indexes.
The format for
L.mapbox.geocoder
andL.mapbox.geocoderControl
results have changed. Results are now provided in GeoJSON format. If your code usesL.mapbox.geocoder
or thefound
,select
, orautoselect
events fromL.mapbox.geocoderControl
, it may need to be updated to expect the format documented in those classes.L.mapbox.config.HTTP_URLS
andL.mapbox.config.HTTPS_URLS
have been replaced withL.mapbox.config.HTTP_URL
andL.mapbox.config.HTTPS_URL
, which expect to be assigned a single URL rather than an array of URLs. For example, replaceL.mapbox.config.HTTP_URLS = ["http://example.com/"];
with
L.mapbox.config.HTTP_URL = "http://example.com/";
L.mapbox.tileLayer
no longer supportsdetectRetina
,retinaVersion
, orautoscale
options. Instead, retina tiles are always automatically used when available.L.mapbox.geocoder
no longer hassetURL
,setID
, andsetTileJSON
methods. Instead of resetting the URL or ID, construct a new instance with the desired URL or ID. Instead of setting TileJSON, construct an instance from the geocoding URL in the TileJSON.