GeoJSON
Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to render geographic data in the GeoJSON
format, using GMUGeoJSONParser
, in
conjunction with GMUGeometryRenderer
. GeoJSON is a popular
format for rendering geographic data such as points, lines, and polygons.
Prerequisites and notes
GMUGeoJSONParser
is part of
the Maps SDK for iOS Utility Library. If you haven't yet set up
the library, follow the setup guide before reading the rest of this page.
For the full code sample, see the sample apps
on
GitHub.
Rendering GeoJSON data
To render GeoJSON data on a map, create a GMUGeoJSONParser
with
the path to a GeoJSON resource (GeoJSON_sample.kml
in this
example). Then, create a GMUGeometryRenderer
, passing the
GMUKMLParser
instance. Finally, call
GMUGeometryRenderer.render()
. The following code example shows
rendering GeoJSON data on a map:
Swift
import GoogleMapsUtils
class GeoJSON {
private var mapView: GMSMapView!
func renderGeoJSON() {
guard let path = Bundle.main.path(forResource: "GeoJSON_sample", ofType: "json") else {
return
}
let url = URL(fileURLWithPath: path)
let geoJsonParser = GMUGeoJSONParser(url: url)
geoJsonParser.parse()
let renderer = GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.features)
renderer.render()
}
}
Objective-C
@import GoogleMapsUtils;
@implementation GeoJSON {
GMSMapView *_mapView;
}
- (void)renderGeoJSON {
NSString *path = [[NSBundle mainBundle] pathForResource:@"GeoJSON_sample" ofType:@"json"];
NSURL *url = [NSURL fileURLWithPath:path];
GMUGeoJSONParser *parser = [[GMUGeoJSONParser alloc] initWithURL:url];
[parser parse];
GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView
geometries:parser.features];
[renderer render];
}
@end
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-28 UTC.
[null,null,["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eThis page demonstrates how to render geographic data in GeoJSON format on Google Maps using the \u003ccode\u003eGMUGeoJSONParser\u003c/code\u003e and \u003ccode\u003eGMUGeometryRenderer\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eGeoJSON is a commonly used format for displaying geographic data like points, lines, and polygons.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need to set up the Maps SDK for iOS Utility Library before using \u003ccode\u003eGMUGeoJSONParser\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples show how to render GeoJSON data on a map in both Swift and Objective-C.\u003c/p\u003e\n"]]],["The document explains how to render GeoJSON data on a map using the `GMUGeoJSONParser` and `GMUGeometryRenderer` from the Maps SDK for iOS Utility Library. First, a `GMUGeoJSONParser` is created with the GeoJSON resource path. Then, a `GMUGeometryRenderer` is initialized with the map view and the parser's features. Finally, the `GMUGeometryRenderer.render()` method is called to display the GeoJSON data, such as points, lines, and polygons, on the map.\n"],null,["Select platform: [Android](/maps/documentation/android-sdk/utility/geojson \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/utility/geojson \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/datalayer \"View this page for the JavaScript platform docs.\")\n\nThis page shows you how to render geographic data in the GeoJSON\nformat, using `GMUGeoJSONParser`, in\nconjunction with `GMUGeometryRenderer`. GeoJSON is a popular\nformat for rendering geographic data such as points, lines, and polygons.\n\nPrerequisites and notes\n\n`GMUGeoJSONParser` is part of\nthe [Maps SDK for iOS Utility Library](https://github.com/googlemaps/google-maps-ios-\nutils). If you haven't yet set up\nthe library, follow the [setup guide](/maps/documentation/ios-\nsdk/utility/setup) before reading the rest of this page.\n\nFor the full code sample, see the sample apps\n[on\nGitHub](https://github.com/googlemaps/google-maps-ios-utils).\n\nRendering GeoJSON data\n\nTo render GeoJSON data on a map, create a `GMUGeoJSONParser` with\nthe path to a GeoJSON resource (`GeoJSON_sample.kml` in this\nexample). Then, create a `GMUGeometryRenderer`, passing the\n`GMUKMLParser` instance. Finally, call\n`GMUGeometryRenderer.render()`. The following code example shows\nrendering GeoJSON data on a map: \n\nSwift \n\n```swift\nimport GoogleMapsUtils\n\nclass GeoJSON {\n private var mapView: GMSMapView!\n\n func renderGeoJSON() {\n guard let path = Bundle.main.path(forResource: \"GeoJSON_sample\", ofType: \"json\") else {\n return\n }\n\n let url = URL(fileURLWithPath: path)\n\n let geoJsonParser = GMUGeoJSONParser(url: url)\n geoJsonParser.parse()\n\n let renderer = GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.features)\n renderer.render()\n }\n}\n \n```\n\nObjective-C \n\n```objective-c\n@import GoogleMapsUtils;\n\n@implementation GeoJSON {\n GMSMapView *_mapView;\n}\n\n- (void)renderGeoJSON {\n NSString *path = [[NSBundle mainBundle] pathForResource:@\"GeoJSON_sample\" ofType:@\"json\"];\n NSURL *url = [NSURL fileURLWithPath:path];\n GMUGeoJSONParser *parser = [[GMUGeoJSONParser alloc] initWithURL:url];\n [parser parse];\n GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView\n geometries:parser.features];\n [renderer render];\n}\n\n@end\n \n```"]]