質問編集履歴
3
画像の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -73,4 +73,7 @@
|
|
73
73
|
map?.addAnnotation(myAnnotation)
|
74
74
|
|
75
75
|
}
|
76
|
-
```
|
76
|
+
```
|
77
|
+
|
78
|
+
・現状の表示
|
79
|
+

|
2
コードの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,4 +12,65 @@
|
|
12
12
|
・[Yahoo! iOSマップSDKをSwiftで使ってみる](http://qiita.com/k-yamada@github/items/1826b31bc9a55eea10be)
|
13
13
|
|
14
14
|
Yahoo! iOSマップSDKドキュメント
|
15
|
-
・[アイコンを表示する](http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/iphonesdk/tutorial4.html)
|
15
|
+
・[アイコンを表示する](http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/iphonesdk/tutorial4.html)
|
16
|
+
|
17
|
+
```ここに言語を入力
|
18
|
+
import UIKit
|
19
|
+
|
20
|
+
|
21
|
+
class MyAnnotation: NSObject, YMKAnnotation {
|
22
|
+
private(set) var coordinate: CLLocationCoordinate2D
|
23
|
+
var annotationTitle: String?
|
24
|
+
var annotationSubtitle: String?
|
25
|
+
|
26
|
+
init(locationCoordinate coord: CLLocationCoordinate2D, title annTitle: String?, subtitle annSubtitle: String?) {
|
27
|
+
coordinate = coord
|
28
|
+
annotationTitle = annTitle
|
29
|
+
annotationSubtitle = annSubtitle
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
func title() -> String? {
|
34
|
+
return annotationTitle
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
func subtitle() -> String? {
|
39
|
+
return annotationSubtitle
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
class ViewController: UIViewController,YMKMapViewDelegate {
|
46
|
+
var map: YMKMapView?
|
47
|
+
|
48
|
+
override func viewDidLoad() {
|
49
|
+
super.viewDidLoad()
|
50
|
+
|
51
|
+
// YMKMapViewのインスタンスを作成
|
52
|
+
map = YMKMapView(frame: CGRect(x: 0, y: 0, width: 320, height: 320), appid: "アプリID")
|
53
|
+
|
54
|
+
// 地図のタイプを指定 標準の地図を指定
|
55
|
+
map!.mapType = UInt(YMKMapTypeStandard)
|
56
|
+
|
57
|
+
// YMKMapViewを追加
|
58
|
+
self.view = map!
|
59
|
+
|
60
|
+
// YMKMapViewDelegateを登録
|
61
|
+
map!.delegate = self
|
62
|
+
|
63
|
+
// 地図の位置と縮尺を設定
|
64
|
+
var center = CLLocationCoordinate2D.init();
|
65
|
+
center.latitude = 35.6657214;
|
66
|
+
center.longitude = 139.7310058;
|
67
|
+
|
68
|
+
map!.region = YMKCoordinateRegionMake(center, YMKCoordinateSpanMake(0.002, 0.002));
|
69
|
+
|
70
|
+
//ピン1個表示
|
71
|
+
let coordinate = CLLocationCoordinate2D(latitude: 35.6657214, longitude: 139.7310058)
|
72
|
+
let myAnnotation = MyAnnotation(locationCoordinate: coordinate, title: "ミッドタウン", subtitle: "ミッドタウンです。")
|
73
|
+
map?.addAnnotation(myAnnotation)
|
74
|
+
|
75
|
+
}
|
76
|
+
```
|
1
コードの削除、実現したいことの記入
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,20 +5,11 @@
|
|
5
5
|
地図の表示はできましたが、その地図上の任意の場所にピン(アイコン)を表示させる実装ができません。
|
6
6
|
objc2swiftも使いましたが、上手くいきません。
|
7
7
|
|
8
|
+
実現したいこととしては、
|
9
|
+
"Yahoo! iOSマップSDKをSwiftで使ってみる"の地図の表示に、複数の任意の場所にアイコンを表示させるといったことをSwift3対応で実装したいと考えております。
|
10
|
+
|
8
11
|
ベースは下記の"Yahoo! iOSマップSDKをSwiftで使ってみる"を参考にしています。
|
9
12
|
・[Yahoo! iOSマップSDKをSwiftで使ってみる](http://qiita.com/k-yamada@github/items/1826b31bc9a55eea10be)
|
10
13
|
|
11
14
|
Yahoo! iOSマップSDKドキュメント
|
12
|
-
・[アイコンを表示する](http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/iphonesdk/tutorial4.html)
|
15
|
+
・[アイコンを表示する](http://developer.yahoo.co.jp/webapi/map/openlocalplatform/v1/iphonesdk/tutorial4.html)
|
13
|
-
```Objective-C
|
14
|
-
//YMapKitTestAppDelegate.m
|
15
|
-
|
16
|
-
//アイコンの緯度経度を設定
|
17
|
-
CLLocationCoordinate2D coordinate;
|
18
|
-
coordinate.latitude = 35.665818701569016;
|
19
|
-
coordinate.longitude = 139.73087297164147;
|
20
|
-
//MyAnnotationの初期化
|
21
|
-
MyAnnotation* myAnnotation = [[MyAnnotation alloc] initWithLocationCoordinate:coordinate title:[[NSString alloc] initWithString:@"ミッドタウン"] subtitle:[[NSString alloc] initWithString:@"ミッドタウンです。"]];
|
22
|
-
//AnnotationをYMKMapViewに追加
|
23
|
-
[map addAnnotation:myAnnotation];
|
24
|
-
```
|