Skip to content

Commit

Permalink
[docsprint] Add geolocate trigger example (#9552)
Browse files Browse the repository at this point in the history
Co-authored-by: Adriana Babakanian <[email protected]>
  • Loading branch information
samfader and adrianababakanian authored Apr 20, 2020
1 parent 410fa94 commit 9f18918
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/ui/control/geolocate_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,23 @@ class GeolocateControl extends Evented {
}

/**
* Trigger a geolocation
*
* @returns {boolean} Returns `false` if called before control was added to a map, otherwise returns `true`.
*/
* Trigger a geolocation
*
* @returns {boolean} Returns `false` if called before control was added to a map, otherwise returns `true`.
* @example
* // Initialize the geolocate control.
* var geolocate = new mapboxgl.GeolocateControl({
* positionOptions: {
* enableHighAccuracy: true
* },
* trackUserLocation: true
* });
* // Add the control to the map.
* map.addControl(geolocate);
* map.on('load', function() {
* geolocate.trigger();
* }
*/
trigger() {
if (!this._setup) {
warnOnce('Geolocate control triggered before added to a map');
Expand Down

0 comments on commit 9f18918

Please sign in to comment.