Add a third party vector tile source
To enrich your map, you have the option to incorporate a third-party vector data source into the map.
In this particular example, we are rendering vector data provided by Mapillary.
NPM module setup
npm install --save @maptiler/sdk
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';
config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const map = new Map({
container: 'map',
style: MapStyle.STREETS,
zoom: 12,
center: [-87.622088, 41.878781]
});
map.on('load', function () {
// Add Mapillary sequence layer.
// https://www.mapillary.com/developer/tiles-documentation/#sequence-layer
map.addSource('mapillary', {
'type': 'vector',
'tiles': [
'https://tiles.mapillary.com/maps/vtp/mly1_public/2/{z}/{x}/{y}?access_token=YOUR_MAPILLARY_TOKEN'
],
'minzoom': 6,
'maxzoom': 14
});
map.addLayer(
{
'id': 'mapillary',
'type': 'line',
'source': 'mapillary',
'source-layer': 'sequence',
'layout': {
'line-cap': 'round',
'line-join': 'round'
},
'paint': {
'line-opacity': 0.6,
'line-color': 'rgb(53, 175, 109)',
'line-width': 2
}
},
'River labels'
);
});
map.addControl(new maptilersdk.NavigationControl());
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex">
<title>Add a third party vector tile source</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div id="map"></div>
<script type="module" src="./main.js"></script>
</body>
</html>
body {margin: 0; padding: 0;}
#map {position: absolute; top: 0; bottom: 0; width: 100%;}