fixed issue 192:fixed geolocate control bug (#914)

This commit is contained in:
Rahul singh mawari 2019-10-25 23:11:44 +05:30 committed by Xintong Xia
parent bf6788edaa
commit 874e77464c

View File

@ -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;
}
}
}