Created
February 11, 2023 07:46
-
-
Save ayaysir/65c9482b3c79afd665619d42055c766c to your computer and use it in GitHub Desktop.
[Swift] MKMapView에서 초기 로드시 지도 확대하기 / Delta: 줌 팩터 단위, 2는 2배 줌 아웃(멀어짐), 0.5는 2배 줌 인 (가까워짐)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension MKMapView { | |
/** | |
``delta`` is the zoom factor | |
- 2 will zoom out x2 | |
- .5 will zoom in by x2 | |
*/ | |
func setZoomByDelta(delta: Double, animated: Bool) { | |
var _region = region; | |
var _span = region.span; | |
_span.latitudeDelta *= delta; | |
_span.longitudeDelta *= delta; | |
_region.span = _span; | |
setRegion(_region, animated: animated) | |
} | |
} | |
/* | |
사용 예: | |
override func viewDidLoad() { | |
mapView.setZoomByDelta(delta: pow(2, -13), animated: true) | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment