LoginSignup
6
6

More than 5 years have passed since last update.

MKMapViewで指定した緯度経度を中央表示

Posted at

MKMapViewで指定した緯度経度を中央表示

指定した緯度、経度を中央表示したい場合があるかと思います。
地図上に、現在地ボタンがあり、タップすると現在地を中央表示するなど。

実現方法

UIButtonのイベント等の処理で以下のコードを実行

        //中心座標
        let center = CLLocationCoordinate2DMake(任意の緯度, 任意の経度)
        //表示範囲
        let span = MKCoordinateSpanMake(0.01, 0.01)

        //中心座標と表示範囲をマップに登録する。
        let region = MKCoordinateRegionMake(center, span)
        MapView.setRegion(region, animated:true)

上記の方法で、実現可能です。
他に方法があれば、教えてください!!

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6