> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/ja/data/boundaries/llms.txt)

# Use Boundaries v4 on a map

Mapbox Boundaries can be added to maps and used to create visualizations in various Mapbox products, including [Mapbox Studio](https://console.mapbox.com/studio/), [Mapbox GL JS](https://docs.mapbox.com/mapbox-gl-js/api/), and the Maps SDKs for [iOS](https://docs.mapbox.com/ios/maps/guides/) and [Android](https://docs.mapbox.com/android/maps/guides/). The following examples use Mapbox GL JS.

*It is recommended to first read the **[Mapbox Boundaries reference](https://docs.mapbox.com/ja/data/boundaries/reference/)** if this is your first time building with the product.*

## Basic example

To add Mapbox Boundaries to a Mapbox GL JS map, start with the ['add a vector tile source' example](https://docs.mapbox.com/mapbox-gl-js/example/vector-source/) and add one of the [Boundaries tilesets](https://docs.mapbox.com/ja/data/boundaries/reference/mapbox-boundaries-v4#tilesets) as a source. The source is added with [`promoteId`](https://docs.mapbox.com/style-spec/reference/sources/#vector-promoteId) to use the [`mapbox_id`](https://docs.mapbox.com/ja/data/boundaries/reference/mapbox-boundaries-v4#mapbox_id-text) property of each feature as the unique identifier in the source.

> **Note: Migrating from v3**
> 
> Using `promoteId` while adding any Boundaries vector tiles sources is required due to [breaking changes to IDs introduced in v4](https://docs.mapbox.com/ja/data/boundaries/reference/mapbox-boundaries-v4#mapbox_id-text). Not using `promoteId` causes data joins and feature state interactions to fail.See the [migration guide](https://docs.mapbox.com/ja/data/boundaries/guides/boundaries-v4-migration-guide/) for additional information.

Then, add a styling layer to the map with this data source filtered by an appropriate [`worldview`](https://docs.mapbox.com/ja/data/boundaries/reference/mapbox-boundaries-v4#worldview-text) filter to remove overlapping boundaries in disputed areas.

For example, to add the first-level administrative division boundaries, we would use the [`admin-1` level tileset](https://docs.mapbox.com/ja/data/boundaries/reference/mapbox-boundaries-v4#tileset-ids). A `worldviewFilter` variable is used to define a [Mapbox GL filter](https://docs.mapbox.com/help/glossary/filter/) to only render features from the `"all"` or `"US"` worldviews.

This creates a map style with Mapbox Boundaries that's ready to have custom data joined into it.

**JavaScript**

```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Use Boundaries v4 on a map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="https://api.mapbox.com/mapbox-gl-js/v3.25.0/mapbox-gl.css" rel="stylesheet">
<script src="https://api.mapbox.com/mapbox-gl-js/v3.25.0/mapbox-gl.js"></script>
<style>
body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
  const map = new mapboxgl.Map({
    // TO MAKE THE MAP APPEAR YOU MUST
    // ADD YOUR ACCESS TOKEN FROM
    // https://account.mapbox.com
    accessToken: 'YOUR_MAPBOX_ACCESS_TOKEN',
    // Choose from Mapbox's core styles, or make your own style with Mapbox Studio
    style: 'mapbox://styles/mapbox/light-v11',
    bounds: [
      [-128.27108, 24.75835],
      [-65.14635, 49.76109]
    ],
    container: 'map',
    antialias: true
  });

  map.on('load', function () {
    // Add a vector source for admin-1 boundaries
    map.addSource('admin-1', {
      type: 'vector',
      url: 'mapbox://mapbox.boundaries-adm1-v4',
      promoteId: 'mapbox_id'
    });

    // Define a filter for US worldview boundaries
    let worldviewFilter = [
      'any',
      ['==', 'all', ['get', 'worldview']],
      ['in', 'US', ['get', 'worldview']]
    ];

    // Add a style layer with the admin-1 source below map labels
    map.addLayer(
      {
        id: 'admin-1-fill',
        type: 'line',
        source: 'admin-1',
        'source-layer': 'boundaries_admin_1',
        filter: worldviewFilter
      },
      // This final argument indicates that we want to add the Boundaries layer
      // before the `waterway-label` layer that is in the map from the Mapbox
      // Light style. This ensures the admin polygons are rendered below any labels
      'waterway-label'
    );
  });
</script>

</body>
</html>
```