Stay organized with collections Save and categorize content based on your preferences.
This page shows you how to render geographic data in the KML format, using GMUKMLParser
in conjunction with GMUGeometryRenderer
. KML is a popular format for rendering geographic data such as points, lines, and polygons.
The following screenshot shows some example KML data rendered on a map:
Prerequisites and notesGMUKMLParser
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 KML dataTo render KML data on a map, create a GMUKMLParser
with the path to a KML resource (KML_Sample.kml
in this example). Then, create a GMUGeometryRenderer
passing the GMUKMLParser
instance. Finally, call GMUGeometryRenderer.render()
. The following code example shows rendering KML data on a map:
import GoogleMapsUtils class KML: NSObject { private var mapView: GMSMapView! func renderKml() { guard let path = Bundle.main.path(forResource: "KML_Sample", ofType: "kml") else { print("Invalid path") return } let url = URL(fileURLWithPath: path) let kmlParser = GMUKMLParser(url: url) kmlParser.parse() let renderer = GMUGeometryRenderer( map: mapView, geometries: kmlParser.placemarks, styles: kmlParser.styles ) renderer.render() } }Objective-C
@import GoogleMapsUtils; @implementation KML { GMSMapView *_mapView; } - (void)renderKml { NSString *path = [[NSBundle mainBundle] pathForResource:@"KML_Sample" ofType:@"kml"]; NSURL *url = [NSURL fileURLWithPath:path]; GMUKMLParser *parser = [[GMUKMLParser alloc] initWithURL:url]; [parser parse]; GMUGeometryRenderer *renderer = [[GMUGeometryRenderer alloc] initWithMap:_mapView geometries:parser.placemarks styles:parser.styles]; [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-07-23 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-23 UTC."],[[["This documentation explains how to render geographic data in KML format using the `GMUKMLParser` and `GMUGeometryRenderer` within the Google Maps SDK for iOS Utility Library."],["KML is a popular format used for displaying geographic data, including points, lines, and polygons, on maps."],["To render KML data, create a `GMUKMLParser` instance with the path to your KML file, then use it to initialize a `GMUGeometryRenderer`, and finally, call `render()` on the renderer to display the data on your map."],["Code examples in both Swift and Objective-C are provided to demonstrate the process of rendering KML data on a map using the Google Maps SDK for iOS."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4