Dispatch a GeolocationError in Geolocation
See https://github.com/openlayers/openlayers/pull/8657#discussion_r219051918
This commit is contained in:
+26
-5
@@ -4,6 +4,7 @@
|
|||||||
import GeolocationProperty from './GeolocationProperty.js';
|
import GeolocationProperty from './GeolocationProperty.js';
|
||||||
import BaseObject, {getChangeEventType} from './Object.js';
|
import BaseObject, {getChangeEventType} from './Object.js';
|
||||||
import {listen} from './events.js';
|
import {listen} from './events.js';
|
||||||
|
import Event from './events/Event.js';
|
||||||
import EventType from './events/EventType.js';
|
import EventType from './events/EventType.js';
|
||||||
import {circular as circularPolygon} from './geom/Polygon.js';
|
import {circular as circularPolygon} from './geom/Polygon.js';
|
||||||
import {GEOLOCATION} from './has.js';
|
import {GEOLOCATION} from './has.js';
|
||||||
@@ -11,6 +12,30 @@ import {toRadians} from './math.js';
|
|||||||
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
|
import {get as getProjection, getTransformFromProjections, identityTransform} from './proj.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @classdesc
|
||||||
|
* Events emitted on Geolocation error.
|
||||||
|
*/
|
||||||
|
class GeolocationError extends Event {
|
||||||
|
/**
|
||||||
|
* @param {PositionError} error error object.
|
||||||
|
*/
|
||||||
|
constructor(error) {
|
||||||
|
super(EventType.ERROR);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.code = error.code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
this.message = error.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
* @property {boolean} [tracking=false] Start Tracking right after
|
* @property {boolean} [tracking=false] Start Tracking right after
|
||||||
@@ -174,12 +199,8 @@ class Geolocation extends BaseObject {
|
|||||||
* @param {PositionError} error error object.
|
* @param {PositionError} error error object.
|
||||||
*/
|
*/
|
||||||
positionError_(error) {
|
positionError_(error) {
|
||||||
const event = {
|
|
||||||
type: EventType.ERROR,
|
|
||||||
target: undefined
|
|
||||||
};
|
|
||||||
this.setTracking(false);
|
this.setTracking(false);
|
||||||
this.dispatchEvent(event);
|
this.dispatchEvent(new GeolocationError(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user