From 874e77464ce435ca488dfbc66042071a6c4d7f2c Mon Sep 17 00:00:00 2001 From: Rahul singh mawari <51601150+sudoStatus200@users.noreply.github.com> Date: Fri, 25 Oct 2019 23:11:44 +0530 Subject: [PATCH] fixed issue 192:fixed geolocate control bug (#914) --- src/components/geolocate-control.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/geolocate-control.js b/src/components/geolocate-control.js index 4ffd59ad..ab90f75b 100644 --- a/src/components/geolocate-control.js +++ b/src/components/geolocate-control.js @@ -110,10 +110,12 @@ export default class GeolocateControl extends BaseControl< componentWillUnmount() { // re-implement MapboxGeolocateControl's _onRemove // clear the geolocation watch if exists - const geolocationWatchID = this._mapboxGeolocateControl._geolocationWatchID; - if (geolocationWatchID !== undefined) { - window.navigator.geolocation.clearWatch(geolocationWatchID); - this._mapboxGeolocateControl._geolocationWatchID = undefined; + if (this._mapboxGeolocateControl) { + const geolocationWatchID = this._mapboxGeolocateControl._geolocationWatchID; + if (geolocationWatchID !== undefined) { + window.navigator.geolocation.clearWatch(geolocationWatchID); + this._mapboxGeolocateControl._geolocationWatchID = undefined; + } } }