質問編集履歴

4

写真の追加

2019/07/22 18:38

投稿

AppDvl
AppDvl

スコア58

test CHANGED
File without changes
test CHANGED
@@ -117,3 +117,9 @@
117
117
 
118
118
 
119
119
  ```
120
+
121
+
122
+
123
+ storyboard     シミュレーター
124
+
125
+ ![イメージ説明](d36adf1a8bcf7f3a5ffc367fb53afc82.png)![イメージ説明](49af32cfac65f47e8d526c430d4274b2.png)

3

2019/07/22 18:37

投稿

AppDvl
AppDvl

スコア58

test CHANGED
@@ -1 +1 @@
1
- マップオーバーレイが出来ない
1
+ 関数が実行されず、マップオーバーレイが出来ない
test CHANGED
File without changes

2

質問のアプローチを変えた

2019/07/21 10:32

投稿

AppDvl
AppDvl

スコア58

test CHANGED
File without changes
test CHANGED
@@ -1,28 +1,28 @@
1
- ### mapに図を表示したい
1
+ ######実現したいこと
2
2
 
3
-
4
-
5
- 画面上のボタンmeasureButton押したら座標を配列coordinateListに記録し、そ座標でmap上に多角形表示したい。
3
+ 変数DmapのMKMapView型の上にサークルオーバーレイしたい。
6
4
 
7
5
 
8
6
 
9
7
 
10
8
 
9
+ ######試したこと
10
+
11
+ print("Dmapが呼ばれた")を func Dmap() の中に記入してもプリントアウトで表示されていないので、func Dmap()が実行されていないことが原因だと思います。
12
+
13
+ そこで //addOverlayした際に呼ばれるデリゲートメソッド のところで
14
+
15
+ テキストだとfunc mapView となっていたのですが、func Dmap()に変えてみましたが結果は同じでした。
16
+
17
+ エラーなどは出ていません。
18
+
19
+
20
+
21
+ この件で数日躓いています、どなたかご教授お願いします。
11
22
 
12
23
 
13
24
 
14
25
 
15
- ### 発生している問題はfunc mapView()内の処理が行われない
16
-
17
- プリントアウトで” print("funcの中(coordinateList)で要素数は(coordinateList.count)")”の部分が表示されて無いので処理が行われていないことはわかりますが、対処の方法がわかりません。
18
-
19
- エラーメッセージなどは表示されていません。
20
-
21
- すべてのコードを載せると10000文字を超えてしまうので当該問題の”measureButton”の部分を記載します。
22
-
23
-
24
-
25
- 見にくいコードだと思いますが、どなたかご教授お願いします。
26
26
 
27
27
 
28
28
 
@@ -32,119 +32,67 @@
32
32
 
33
33
  ```
34
34
 
35
- @IBAction func measureButton(_ sender: Any) {
35
+ import UIKit
36
36
 
37
- print("Buttonを押した")
37
+ import MapKit
38
38
 
39
- if coordinates[0][0] == 1.0 {
40
39
 
41
- coordinates[0][0] = latitude
42
40
 
43
- coordinates[0][1] = longitude
41
+ class ViewController: UIViewController,MKMapViewDelegate {
44
42
 
45
-
43
+ @IBOutlet weak var Dmap: MKMapView!
46
44
 
47
- polygon = CLLocationCoordinate2DMake(latitude,longitude)
45
+
48
46
 
49
- coordinateList.append(polygon)
47
+ override func viewDidLoad() {
50
48
 
51
- print("ifの中(coordinateList)で要素数は(coordinateList.count)")
49
+ super.viewDidLoad()
52
50
 
53
- tableView.reloadData()//tableView更新
51
+ let clocation : CLLocationCoordinate2D = CLLocationCoordinate2DMake(35.703056, 139.58) //中心座標ように定義
54
52
 
55
- }else{
53
+ let circleOverlay : MKCircle = MKCircle(center: clocation , radius: 100) //MKCircle型の定義
56
54
 
57
- coordinates.append([latitude,longitude])
58
55
 
59
- polygon = CLLocationCoordinate2DMake(latitude,longitude)
60
-
61
- coordinateList.append(polygon)
62
-
63
- print("elseの後(coordinateList)で要素数は(coordinateList.count)")
64
-
65
- }
66
56
 
67
57
 
68
58
 
69
- if coordinateList.count >= 2 {
59
+ let span = MKCoordinateSpan(latitudeDelta: 0.001,longitudeDelta: 0.001)//地図の範囲 緯度経度の差
70
60
 
71
- //多角形マップビューに追加する。
61
+ let region = MKCoordinateRegion(center: clocation, span: span) //中心と範囲定義
72
62
 
73
- let overlay = MKPolygon(coordinates: &coordinateList, count: coordinateList.count)
63
+ Dmap.setRegion(region, animated: true)
74
64
 
75
- map.addOverlay(overlay)
65
+ Dmap.addOverlay(circleOverlay)//Mapをセット
76
66
 
77
-
67
+ // Do any additional setup after loading the view.
78
68
 
79
- print("func mapView()の前")
69
+
80
70
 
81
- //バーレイを表示
71
+ //addOverlayした際に呼ばれるデリゲトメソッド
82
72
 
83
- func mapView(mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
73
+ func Dmap(mapView:MKMapView,rendererFor overlay:MKOverlay)-> MKOverlayRenderer{ //rendererはレンダラー→レンダリング装置→レンダリングは生成する事
84
74
 
85
- let renderer = MKPolygonRenderer(polygon: overlay as! MKPolygon)
75
+ let renderer : MKCircleRenderer = MKCircleRenderer(circle: overlay as! MKCircle)
86
76
 
87
- renderer.lineWidth = 1
77
+ print("Dmapが呼ばれた")
88
78
 
89
- renderer.strokeColor = UIColor.red
79
+ renderer.lineWidth = 1
90
80
 
91
- renderer.fillColor = UIColor.red
81
+ renderer.strokeColor = UIColor.blue
92
82
 
93
- renderer.alpha = 0.3
83
+ renderer.fillColor = UIColor.blue
94
84
 
95
- print("funcの中(coordinateList)で要素数は(coordinateList.count)")
85
+ renderer.alpha = 0.3
96
86
 
97
- return renderer
87
+ return renderer
98
-
99
- }
100
-
101
- tableView.reloadData()//tableViewの更新
102
-
103
- }
104
-
105
- print(coordinates)
106
88
 
107
89
  }
108
90
 
109
- ```
91
+ }
110
92
 
111
93
 
112
94
 
113
- ### プリントアウト
114
-
115
- 座標は????に書き換えてます。
116
-
117
- ```ここに言語名を入力
118
-
119
- 2019-07-10 22:12:04.178426+0900 Wood volume[35309:7483474] [Accessibility] ****************** Loading GAX Client Bundle ****************
120
-
121
- [[1.0, 1.0]]
122
-
123
- satelliteFlyover
124
-
125
- 常時、位置情報の取得が許可されています。
126
-
127
- Buttonを押した
128
-
129
- ifの中[__C.CLLocationCoordinate2D(latitude: 30.????????????, longitude: 130.????????)]で要素数は1
130
-
131
- [[30.????????????, longitude: 130.????????]]
132
-
133
- Buttonを押した
134
-
135
- elseの後[__C.CLLocationCoordinate2D(llatitude: 30.????????????, longitude: 130.????????), __C.CLLocationCoordinate2D(latitude: 30.????????????, longitude: 130.????????)]で要素数は2
136
-
137
- func mapView()の前
138
-
139
- [[30.????????????, 130.????????], [30.????????????, 130.????????]]
140
-
141
- Buttonを押した
142
-
143
- elseの後[__C.CLLocationCoordinate2D(latitude: 30.????????????, longitude: 130.????????), __C.CLLocationCoordinate2D(latitude: 30.????????????, longitude: 130.????????), __C.CLLocationCoordinate2D(latitude: 30.????????????, longitude: 130.????????)]で要素数は3
144
-
145
- func mapView()の前
146
-
147
- [ [30.????????????, 130.????????], [30.????????????, 130.????????], [30.????????????, 130.????????]]
95
+ }
148
96
 
149
97
 
150
98
 
@@ -152,6 +100,20 @@
152
100
 
153
101
 
154
102
 
103
+ プリントアウト
104
+
105
+ ```
106
+
107
+ 2019-07-20 13:07:03.332828+0900 map[2590:157293] [AXMediaCommon] Unable to look up screen scale
108
+
109
+ 2019-07-20 13:07:03.333011+0900 map[2590:157293] [AXMediaCommon] Unexpected physical screen orientation
110
+
111
+ 2019-07-20 13:07:03.382356+0900 map[2590:157293] [AXMediaCommon] Unable to look up screen scale
112
+
113
+ 2019-07-20 13:07:03.410909+0900 map[2590:157293] [AXMediaCommon] Unable to look up screen scale
114
+
115
+ 2019-07-20 13:07:03.411050+0900 map[2590:157293] [AXMediaCommon] Unexpected physical screen orientation
155
116
 
156
117
 
118
+
157
- ここにより詳細な情報を記載してください。
119
+ ```

1

コードを追加しました。

2019/07/20 04:14

投稿

AppDvl
AppDvl

スコア58

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- 画面上のボタン押したら座標を配列coordinateListに記録し、その座標でmap上に多角形を表示したい。
5
+ 画面上のボタンmeasureButton押したら座標を配列coordinateListに記録し、その座標でmap上に多角形を表示したい。
6
6
 
7
7
 
8
8
 
@@ -17,6 +17,8 @@
17
17
  プリントアウトで” print("funcの中(coordinateList)で要素数は(coordinateList.count)")”の部分が表示されて無いので処理が行われていないことはわかりますが、対処の方法がわかりません。
18
18
 
19
19
  エラーメッセージなどは表示されていません。
20
+
21
+ すべてのコードを載せると10000文字を超えてしまうので当該問題の”measureButton”の部分を記載します。
20
22
 
21
23
 
22
24