質問するログイン新規登録

回答編集履歴

2

修正

2017/01/29 10:39

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -39,4 +39,6 @@
39
39
  map!.region = YMKCoordinateRegionMake(center, YMKCoordinateSpanMake(0.002, 0.002));
40
40
  }
41
41
  }
42
- ```
42
+ ```
43
+
44
+ ![s](e226205fe60021c9866355b74b4d9b28.png)

1

修正

2017/01/29 10:39

投稿

_Kentarou
_Kentarou

スコア8490

answer CHANGED
@@ -8,4 +8,35 @@
8
8
  ```
9
9
 
10
10
 
11
- [Yahoo! iOSマップSDKをSwiftで使ってみる](http://qiita.com/k-yamada@github/items/1826b31bc9a55eea10be)
11
+ [Yahoo! iOSマップSDKをSwiftで使ってみる](http://qiita.com/k-yamada@github/items/1826b31bc9a55eea10be)
12
+
13
+ 準備ができていれば以下のコードだけで地図が表示できます。
14
+
15
+ ```swift
16
+ import UIKit
17
+
18
+ class ViewController: UIViewController, YMKMapViewDelegate {
19
+ var map: YMKMapView?
20
+
21
+ override func viewDidLoad() {
22
+ super.viewDidLoad()
23
+ // YMKMapViewのインスタンスを作成
24
+ map = YMKMapView(frame: CGRect(x: 0, y: 0, width: 320, height: 320), appid: "アプリケーションID")
25
+
26
+ // 地図のタイプを指定 標準の地図を指定
27
+ map!.mapType = UInt(YMKMapTypeStandard)
28
+
29
+ // YMKMapViewを追加
30
+ self.view = map!
31
+
32
+ // YMKMapViewDelegateを登録
33
+ map!.delegate = self
34
+
35
+ // 地図の位置と縮尺を設定
36
+ var center = CLLocationCoordinate2D.init();
37
+ center.latitude = 35.6657214;
38
+ center.longitude = 139.7310058;
39
+ map!.region = YMKCoordinateRegionMake(center, YMKCoordinateSpanMake(0.002, 0.002));
40
+ }
41
+ }
42
+ ```