Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding geojson layer to google map in iOS

I am writing my first iOS native app. I am trying to load a GeoJSON layer onto a google map in the app (map comes from the google maps sdk) but I can't find any way to do it. I'm proficient in the google maps javascript API but I'm sensing things in Swift are very different.

How can I load a GeoJSON layer onto a map in a native iOS app?

like image 641
TC McCarthy Avatar asked Dec 14 '25 00:12

TC McCarthy


1 Answers

First add your geoJSON file to your project. And if you have google maps set up than you can use the following:

let path = Bundle.main.path(forResource: "GeoJSON_sample", ofType: "json")
let url = URL(fileURLWithPath: path!)
geoJsonParser = GMUGeoJSONParser(url: url)
geoJsonParser.parse()

let renderer = GMUGeometryRenderer(map: mapView, geometries: geoJsonParser.features)
renderer.render()
like image 67
FredFlinstone Avatar answered Dec 16 '25 17:12

FredFlinstone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!