<!--
{
  "availability" : [
    "MapKit JS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/mapkit/importGeoJSON",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "instm/mapkit/importGeoJSON"
  },
  "title" : "importGeoJSON(data, callback)"
}
-->

# importGeoJSON(data, callback)

Converts imported GeoJSON data to MapKit JS compatible items.

```
importGeoJSON(
    data: string | GeoJSONTypes.GeoJSON,
    callback?: GeoJSONDelegate | GeoJSONImporterCallback,
):
    | ItemCollection<
          GeoJSONTypes.GeoJSON<
              GeoJSONTypes.Geometry,
              GeoJSONTypes.GeoJsonProperties
          >
      >
    | undefined;
```

## Parameters

`data`

The original GeoJSON data, either a URL to a GeoJSON file, or a GeoJSON object.

`callback`

A callback function or an object that MapKit JS requires if you provide a URL for the `data` parameter. It’s optional, otherwise.

## Return Value

If the data argument is a GeoJSON object instead of a URL and you don’t provide a `callback` function, [`importGeoJSON(data, callback)`](/documentation/MapKitJS/mapkit/importGeoJSON) returns an [`ItemCollection`](/documentation/MapKitJS/ItemCollection). If the data import fails, this method returns an error.

## Discussion

> Note:
> You must load the `geojson` library first before accessing the method, otherwise, the method throws an `Error`.

This function converts imported GeoJSON data into MapKit JS items, which are [`Annotation`](/documentation/MapKitJS/mapkit/Annotation), [`Overlay`](/documentation/MapKitJS/Overlay), and [`ItemCollection`](/documentation/MapKitJS/ItemCollection) objects. Access the original GeoJSON data through the object’s [`data`](/documentation/MapKitJS/ItemCollection/data) property.

You can customize the import by implementing a [`GeoJSONDelegate`](/documentation/MapKitJS/GeoJSONDelegate) delegate:

- If you provide a GeoJSON object for the `data` parameter, [`importGeoJSON(data, callback)`](/documentation/MapKitJS/mapkit/importGeoJSON) returns the result directly. However, the system uses the optional callback, if you provide it.
- If you provide a URL to a GeoJSON file in the `data` parameter, you need to provide a callback function or delegate object.

> Note:
> GeoJSON is a format that encodes geographic data. See the GeoJSON standard specification [RFC 7946](https://tools.ietf.org/html/rfc7946) for more information.

---

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)