使った事がなかったのですが、以下のサイトを参考に地図を表示するところまでできました。
自分はXcode8.2.1
, iOS10.2
でできたので問題無いと思います。
importでエラーになるのはHoge-Bridging-Header.h
を作成して以下を記述していないのが原因では無いでしょうか?
#import <YMapKit/YMapKit.h>
Yahoo! iOSマップSDKをSwiftで使ってみる
準備ができていれば以下のコードだけで地図が表示できます。
swift
1import UIKit
2
3class ViewController: UIViewController, YMKMapViewDelegate {
4 var map: YMKMapView?
5
6 override func viewDidLoad() {
7 super.viewDidLoad()
8 // YMKMapViewのインスタンスを作成
9 map = YMKMapView(frame: CGRect(x: 0, y: 0, width: 320, height: 320), appid: "アプリケーションID")
10
11 // 地図のタイプを指定 標準の地図を指定
12 map!.mapType = UInt(YMKMapTypeStandard)
13
14 // YMKMapViewを追加
15 self.view = map!
16
17 // YMKMapViewDelegateを登録
18 map!.delegate = self
19
20 // 地図の位置と縮尺を設定
21 var center = CLLocationCoordinate2D.init();
22 center.latitude = 35.6657214;
23 center.longitude = 139.7310058;
24 map!.region = YMKCoordinateRegionMake(center, YMKCoordinateSpanMake(0.002, 0.002));
25 }
26}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/29 10:36
2017/01/29 10:41 編集
2017/01/29 10:58
2017/01/29 11:19
2017/01/29 11:57