Skip to content

CLLocationErrorEvent ​

CLLocationErrorEvent represents a location error.

The locationerror event of CLLocationManager is this class, and error is the error.

It belongs to the @nacrejs/core-location package; for installation, see CLLocationManager.

Inheritance: Event → CLLocationErrorEvent

Constructor ​

CLLocationErrorEvent()

Creates a CLLocationErrorEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.

Instance properties ​

Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.

PropertyDescription
error read-onlyThe error

These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.

Events that use this class ​

ObjectEvents
CLLocationManagerlocationerror

It can't be canceled: cancelable is false, and preventDefault() has no effect.

Examples ​

js
const manager = new CLLocationManager();
manager.addEventListener('locationerror', (e) => {
  console.log(e instanceof CLLocationErrorEvent, e.error.name);
});
manager.startUpdatingLocation();

Effect: when a location error occurs, prints true and the error category. Not verified in the simulator.

Corresponding iOS API ​

ObjCJS
locationManager:didFailWithError:The locationerror event
The error parameterevent.error

See also ​