Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Current Center Position Mapbox GL JS

Looking for a way to get the current coordinates of the center of a map using Mapbox GL JS the same way they do on Mapbox Studio (see below)

Mapbox Studio Screenshot

Thanks

like image 768
MalloryMan Avatar asked Feb 20 '18 21:02

MalloryMan


People also ask

How do I get coordinates from Mapbox?

If you need to find a location's latitude and longitude, you can use the Mapbox Search playground, which allows you to search for a location and retrieve its coordinates in longitude,latitude format.

How do I center a map in Mapbox?

Use events and flyTo to center the map on a feature in a circle layer. // Add a GeoJSON source with 3 points. }); // Center the map on the coordinates of any clicked circle from the 'circle' layer.

What is bearing in Mapbox?

When you are viewing a Mapbox map, the bearing rotates the map around its center the specified number of degrees. The bearing of your map view can be adjusted in many Mapbox products, including Mapbox Studio, Mapbox GL JS, the Mapbox Maps SDKs for Android and iOS, and the Static Images API.

How do I add a point of interest to Mapbox?

You can use the draw tools in the Mapbox Studio dataset editor to add a new point to your dataset. You can also change the geometry, placement, and properties of existing features with the dataset editor's draw tools.


1 Answers

The Map#getCenter method returns the coordinates of the center of the map.

like image 199
Lucas Wojciechowski Avatar answered Sep 21 '22 02:09

Lucas Wojciechowski