Skip to content

Instantly share code, notes, and snippets.

@sora0077
sora0077 / MKMapView+Extensions.swift
Last active November 24, 2020 14:41 — forked from appsandwich/MKMapView+Extensions
Get & set the zoom level of a MKMapView
import MapKit
// http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/
private let mercadorRadius: Double = 85445659.44705395
private let mercadorOffset: Double = 268435456
private func longitudeToPixelSpaceX(longitude: Double) -> Double {
return round(mercadorOffset + mercadorRadius * longitude * .pi / 180.0);
}