<!--
{
  "availability" : [
    "MapKit JS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/MapUserLocationErrorEvent/code",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "instp/mapkit.MapUserLocationErrorEvent/code"
  },
  "title" : "code"
}
-->

# code

The code indicating why location acquisition failed.

```
readonly code: number;
```

## Discussion

The error codes mirror the HTML Geolocation API’s error codes with one additional MapKit JS-specific error code:

- `Error.PERMISSION_DENIED` (`1`): The user refuses permission to obtain location information.
- `Error.POSITION_UNAVAILABLE` (`2`): The Geolocation API returns an error.
- `Error.TIMEOUT` (`3`): The operation times out without acquiring the location.
- `Error.MAPKIT_NOT_INITIALIZED` (`4`): MapKit JS isn’t initialized.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)