---
title: "importGeoJSON(data, callback)"
framework: mapkitjs
role: symbol
role_heading: Instance Method
path: mapkitjs/mapkit/importgeojson
---

# importGeoJSON(data, callback)

Converts imported GeoJSON data to MapKit JS compatible items.

## Declaration

```data
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.

## Mentioned in

MapKit JS 5

## Return Value

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) returns an ItemCollection. If the data import fails, this method returns an error.

## Discussion

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, Overlay, and ItemCollection objects. Access the original GeoJSON data through the object’s data property. You can customize the import by implementing a GeoJSONDelegate delegate: If you provide a GeoJSON object for the data parameter, importGeoJSON(data, callback) 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 for more information.

## See Also

### Geographical features

- [GeoJSONDelegate](mapkitjs/geojsondelegate.md)
- [Item](mapkitjs/item.md)
- [ItemCollection](mapkitjs/itemcollection.md)
- [GeoJSONImporterCallback](mapkitjs/geojsonimportercallback.md)
- [GeoJSONImportError](mapkitjs/geojsonimporterror.md)
- [Displaying Indoor Maps with MapKit JS](mapkitjs/displaying-indoor-maps-with-mapkit-js.md)
