---
title: "MTGeoJSONParser | Mobile sdk | Mobile sdk ios | Ios"
description: "A utility to parse GeoJSON and extract coordinates for use with offline regions or other geometry models."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTGeoJSONParser

```
public struct MTGeoJSONParser : Sendable
```

A utility to parse GeoJSON and extract coordinates for use with offline regions or other geometry models.

-   `[extractCoordinates(from:)](#/s:11MapTilerSDK15MTGeoJSONParserV18extractCoordinates4fromSaySo22CLLocationCoordinate2DVG10Foundation4DataV_tKFZ)`
    
    Extracts a flat array of coordinates from a GeoJSON payload.
    
    This is particularly useful for generating `MTOfflineRegionGeometry.route` or `.polygon` from existing GeoJSON files containing `LineString`, `Polygon`, `MultiLineString`, or `MultiPolygon` geometries.
    
    Throws
    
    `DecodingError` if the GeoJSON is invalid or cannot be parsed.
    
    #### Declaration
    
    Swift
    
    ```
    public static func extractCoordinates(from data: Data) throws -> [CLLocationCoordinate2D]
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>data</em></code></td><td><div><p>The raw GeoJSON data.</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    An array of `CLLocationCoordinate2D` extracted from the GeoJSON.
    
-   `[extractCoordinates(from:)](#/s:11MapTilerSDK15MTGeoJSONParserV18extractCoordinates4fromSaySo22CLLocationCoordinate2DVGSS_tKFZ)`
    
    Extracts a flat array of coordinates from a GeoJSON string.
    
    Throws
    
    An error if the string is invalid or cannot be parsed.
    
    #### Declaration
    
    Swift
    
    ```
    public static func extractCoordinates(from string: String) throws -> [CLLocationCoordinate2D]
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>string</em></code></td><td><div><p>The GeoJSON string.</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    An array of `CLLocationCoordinate2D`.
