iosswiftgoogle-mapsmapkitgoogle-map-tiles-api

How to use google map tiles with MapKit?


I need to attach google map tiles as MKTileOverlay to MapKit.

Google documentation tells me to use url template like "https://tile.googleapis.com/tile/v1/viewport?session=YOUR_SESSION_TOKEN&key=YOUR_API_KEY&zoom=ZOOM&north=NORTH&south=SOUTH&east=EAST&west=WEST".

But MKTileOverlay expects url in other format, like this "https://tiles.x-gpsmail.com/iry8ordl8v/styles/squaregps-basic/{z}/{x}/{y}.png"

I assume, i need to override MKTileOverlay func url(forTilePath path: MKTileOverlayPath) -> URL, but i have no idea how to construct it according to google template

Or maybe some other way to use google tiles with MapKit?

(i can't use google maps sdk due to big number of custom logic already running over MapKit sdk)


Solution

  • i have figured out. here is suitable url format for MapKit curl "https://tile.googleapis.com/v1/2dtiles/z/x/y?session=YOUR_SESSION_TOKEN&key=YOUR_API_KEY&orientation=0_or_90_or_180_or_270"