From c201f06bfeb627d7d2a5af5d6426683adc0d5ab3 Mon Sep 17 00:00:00 2001 From: Jeremy Stratman Date: Mon, 20 Apr 2020 14:49:49 -0700 Subject: [PATCH] added inline and tutorial examples for map.getCenter (#9551) --- src/ui/camera.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ui/camera.js b/src/ui/camera.js index caf116baee6..538e17f05d8 100644 --- a/src/ui/camera.js +++ b/src/ui/camera.js @@ -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); }