Skip to content

Commit

Permalink
add extra geolocate control private method documentation (#9754)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewharvey authored Jun 3, 2020
1 parent 536513d commit 305f4bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
29 changes: 27 additions & 2 deletions src/ui/control/geolocate_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ let noTimeout = false;
* Not all browsers support geolocation,
* and some users may disable the feature. Geolocation support for modern
* browsers including Chrome requires sites to be served over HTTPS. If
* geolocation support is not available, the GeolocateControl will not
* be visible.
* geolocation support is not available, the GeolocateControl will show
* as disabled.
*
* The zoom level applied will depend on the accuracy of the geolocation provided by the device.
*
Expand Down Expand Up @@ -154,6 +154,13 @@ class GeolocateControl extends Evented {
noTimeout = false;
}

/**
* Check if the Geolocation API Position is outside the map's maxbounds.
*
* @param {Position} position the Geolocation API Position
* @returns {boolean} Returns `true` if position is outside the map's maxbounds, otherwise returns `false`.
* @private
*/
_isOutOfMapMaxBounds(position: Position) {
const bounds = this._map.getMaxBounds();
const coordinates = position.coords;
Expand Down Expand Up @@ -194,6 +201,12 @@ class GeolocateControl extends Evented {
}
}

/**
* When the Geolocation API returns a new location, update the GeolocateControl.
*
* @param {Position} position the Geolocation API Position
* @private
*/
_onSuccess(position: Position) {
if (!this._map) {
// control has since been removed
Expand Down Expand Up @@ -256,6 +269,12 @@ class GeolocateControl extends Evented {
this._finish();
}

/**
* Update the camera location to center on the current position
*
* @param {Position} position the Geolocation API Position
* @private
*/
_updateCamera(position: Position) {
const center = new LngLat(position.coords.longitude, position.coords.latitude);
const radius = position.coords.accuracy;
Expand All @@ -267,6 +286,12 @@ class GeolocateControl extends Evented {
});
}

/**
* Update the user location dot Marker to the current position
*
* @param {Position} [position] the Geolocation API Position
* @private
*/
_updateMarker(position: ?Position) {
if (position) {
const center = new LngLat(position.coords.longitude, position.coords.latitude);
Expand Down
1 change: 0 additions & 1 deletion src/util/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

/**
* Throttle the given function to run at most every `period` milliseconds.
Throttle the given function to run at most every period milliseconds.
* @private
*/
export default function throttle(fn: () => void, time: number): () => ?TimeoutID {
Expand Down

0 comments on commit 305f4bc

Please sign in to comment.