Skip to content

Commit

Permalink
added inline and tutorial examples for map.getCenter (#9551)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstratman authored Apr 20, 2020
1 parent 254f29f commit c201f06
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ class Camera extends Evented {
*
* @memberof Map#
* @returns The map's geographical centerpoint.
* @example
* // return a LngLat object such as {lng: 0, lat: 0} at null island
* var center = map.getCenter();
* // return longitude and latitude values directly
* var longitude = map.getCenter().lng;
* var latitude = map.getCenter().lat;
* @see [Use Mapbox GL JS in a React app](https://docs.mapbox.com/help/tutorials/use-mapbox-gl-js-with-react/#store-the-new-coordinates)
*/
getCenter(): LngLat { return new LngLat(this.transform.center.lng, this.transform.center.lat); }

Expand Down

0 comments on commit c201f06

Please sign in to comment.