--- layout: api title: "v2.1.5 JavaScript Library: L.mapbox.map(element, id|url|tilejson, options)" categories: api version: v2.1.5 permalink: /api/v2.1.5/l-mapbox-map ---

## 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 `{{site.tileApi}}/v3/examples.map-0l53fhk2.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: `tileLayer` L.TileLayer options. Options passed to a `L.mapbox.tileLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.tileLayer`. `featureLayer` `L.mapbox.featureLayer` options. Options passed to a `L.mapbox.featureLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.featureLayer`. `gridLayer` `L.mapbox.gridLayer`. Options passed to a `L.mapbox.gridLayer` based on the TileJSON. Set to `false` to disable the `L.mapbox.gridLayer`. `legendControl` `L.mapbox.legendControl` options. Options passed to a `L.mapbox.legendControl` based on the TileJSON. Set to `false` to disable the `L.mapbox.legendControl`. `shareControl`: Options passed to a `L.mapbox.shareControl`. Set to `true` to enable the `L.mapbox.shareControl`. `infoControl`: Options passed to a `L.mapbox.infoControl`. Set to `true` to enable the `L.mapbox.infoControl`. `accessToken`: Mapbox API access token. Overrides `L.mapbox.accessToken` for this map.

Example:

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

    // 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`

### map.getTileJSON()

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

Returns: the TileJSON object