diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 42db02f0a2..3825d1df6a 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -4,6 +4,16 @@ #### Backwards incompatible changes +#### Removal of `GEOLOCATION` constant from `ol/has` + +If you were previously using this constant, you can check if `'geolocation'` is define in `navigator` instead. + +```js +if ('geolocation' in navigator) { + // ... +} +``` + #### Removal of CSS print rules The CSS media print rules were removed from the `ol.css` file. To get the previous behavior, use the following CSS: diff --git a/src/ol/Geolocation.js b/src/ol/Geolocation.js index 99fbcd7385..1adb35e0b6 100644 --- a/src/ol/Geolocation.js +++ b/src/ol/Geolocation.js @@ -6,7 +6,6 @@ import {listen} from './events.js'; import Event from './events/Event.js'; import EventType from './events/EventType.js'; import {circular as circularPolygon} from './geom/Polygon.js'; -import {GEOLOCATION} from './has.js'; import {toRadians} from './math.js'; import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js'; @@ -160,7 +159,7 @@ class Geolocation extends BaseObject { * @private */ handleTrackingChanged_() { - if (GEOLOCATION) { + if ('geolocation' in navigator) { const tracking = this.getTracking(); if (tracking && this.watchId_ === undefined) { this.watchId_ = navigator.geolocation.watchPosition( diff --git a/src/ol/has.js b/src/ol/has.js index 9902b52940..93b1e93431 100644 --- a/src/ol/has.js +++ b/src/ol/has.js @@ -40,15 +40,6 @@ export const MAC = ua.indexOf('macintosh') !== -1; export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1; -/** - * Is HTML5 geolocation supported in the current browser? - * @const - * @type {boolean} - * @api - */ -export const GEOLOCATION = 'geolocation' in navigator; - - /** * True if browser supports touch events. * @const