importGeoJSON(data, callback)
Converts imported GeoJSON data to MapKit JS compatible items.
Declaration
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
dataparameter. It’s optional, otherwise.
Mentioned in
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
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
dataparameter, 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
dataparameter, you need to provide a callback function or delegate object.