Sign in

Tutorial: Adding OpenStreetMap to your website!

#1911
Verhoeckx

Zooming in a particular location

Add the option center to the map object.

`var map = new mapboxgl.Map({
container: ‘openstreetmap’,
style: ‘mapbox://styles/mapbox/streets-v11’,
center: [longitude, latitude],
zoom: 15
});`

You can find the longitude and latitude of your location by using the Mapbox Playground.

You can find the Mapbox Playground here:

https://docs.mapbox.com/search-playground

Search for your location and click once on the button Toggle JSON panel (in the top right of the website).