Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.

You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.

L.mapbox.map(element, id|url|tilejson, options)

Create and automatically configure a map with layers, markers, and interactivity.

Extends: L.Map

Options Value Description
element (required) string Must be the id of an element, or a DOM element reference.
id or url or tilejson string if id or url object if tilejson url can be
  • A map id string examples.map-foo
  • A comma separated list of map id strings examples.map-foo,examples.map-bar example
  • A URL to TileJSON, like https://api.mapbox.com/v3/mapbox.dark.json
  • A TileJSON object, from your own Javascript code
options object If provided, it is the same options as provided to L.Map with the following additions:


// map refers to a <div> element with the ID map
// mapbox.streets is the ID of a map on Mapbox.com
var map = L.mapbox.map('map', 'mapbox.streets');

// map refers to a <div> element with the ID map
// This map will have no layers initially
var map = L.mapbox.map('map');

Returns: a map object

Class: L.mapbox.Map


Returns this map's TileJSON object which determines its tile source, zoom bounds and other metadata.

Returns: the TileJSON object