質問編集履歴
5
最新のコードに編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -182,90 +182,68 @@
|
|
182
182
|
|
183
183
|
|
184
184
|
|
185
|
+
<!-- Maps JavaScript API(地図)、Places API(入力場所検索ボックス)のapiキー作成し埋め込み ロード時動作 -->
|
186
|
+
|
187
|
+
<script
|
188
|
+
|
189
|
+
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6gVVngdDmxOTy4il-r0utj51VfO0fRqw&libraries=places&callback=initAutocomplete&libraries=places&v=weekly"
|
190
|
+
|
191
|
+
defer>
|
192
|
+
|
193
|
+
</script>
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
<!-- jsファイルアクセス -->
|
200
|
+
|
201
|
+
<script th:src="@{/js/MapsJavaScriptCurrentLocationSearch.js}">
|
202
|
+
|
203
|
+
</script>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
208
|
+
|
209
|
+
</script>
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
214
|
+
|
215
|
+
</script>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
<p>
|
224
|
+
|
225
|
+
<button onclick="getMyPlace()">現在位置を取得</button>
|
226
|
+
|
227
|
+
</p>
|
228
|
+
|
229
|
+
<div id="result"></div>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<!-- 検索ボックス機能 -->
|
234
|
+
|
235
|
+
<input id="pac-input" class="controls" type="text"
|
236
|
+
|
237
|
+
placeholder="Search Box">
|
238
|
+
|
239
|
+
|
240
|
+
|
185
|
-
<!--
|
241
|
+
<!-- マップ表示 -->
|
186
242
|
|
187
243
|
<div id="map"></div>
|
188
244
|
|
189
245
|
|
190
246
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
<p>
|
196
|
-
|
197
|
-
<button onclick="getMyPlace()">現在位置を取得</button>
|
198
|
-
|
199
|
-
</p>
|
200
|
-
|
201
|
-
<div id="result"></div>
|
202
|
-
|
203
|
-
<p>
|
204
|
-
|
205
|
-
<!-- initAutocomplete()呼び出し-->
|
206
|
-
|
207
|
-
<button onclick="initAutocomplete()">検索</button>
|
208
|
-
|
209
|
-
<input id="pac-input" class="controls" type="text"
|
210
|
-
|
211
|
-
placeholder="Search Box">
|
212
|
-
|
213
|
-
</p>
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
<div id="map" style="width: 100%; height: 300px;"></div>
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
<!-- 地図の埋め込み表示 -->
|
232
|
-
|
233
|
-
<div id="map_canvas" style="height: 300px; width: 550px;"></div>
|
234
|
-
|
235
|
-
<script
|
236
|
-
|
237
|
-
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6gVVngdDmxOTy4il-r0utj51VfO0fRqw&libraries=places&callback=initAutocomplete&libraries=places&v=weekly"
|
238
|
-
|
239
|
-
defer>
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
</script>
|
244
|
-
|
245
|
-
<script th:src="@{/js/MapsJavaScriptCurrentLocationSearch.js}">
|
246
|
-
|
247
|
-
</script>
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
</script>
|
256
|
-
|
257
|
-
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
</script>
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
</div>
|
266
|
-
|
267
|
-
|
268
|
-
|
269
247
|
</body>
|
270
248
|
|
271
249
|
</html>
|
@@ -274,7 +252,7 @@
|
|
274
252
|
|
275
253
|
|
276
254
|
|
277
|
-
```
|
255
|
+
```javascript
|
278
256
|
|
279
257
|
function getMyPlace() {
|
280
258
|
|
4
html 編集(callback)
test
CHANGED
File without changes
|
test
CHANGED
@@ -234,11 +234,11 @@
|
|
234
234
|
|
235
235
|
<script
|
236
236
|
|
237
|
-
src="https://maps.googleapis.com/maps/api/js?key=AIzaSy
|
237
|
+
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC6gVVngdDmxOTy4il-r0utj51VfO0fRqw&libraries=places&callback=initAutocomplete&libraries=places&v=weekly"
|
238
238
|
|
239
239
|
defer>
|
240
240
|
|
241
|
-
|
241
|
+
|
242
242
|
|
243
243
|
</script>
|
244
244
|
|
3
html initAutocomplete()呼び出し 記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,62 +202,64 @@
|
|
202
202
|
|
203
203
|
<p>
|
204
204
|
|
205
|
+
<!-- initAutocomplete()呼び出し-->
|
206
|
+
|
207
|
+
<button onclick="initAutocomplete()">検索</button>
|
208
|
+
|
209
|
+
<input id="pac-input" class="controls" type="text"
|
210
|
+
|
211
|
+
placeholder="Search Box">
|
212
|
+
|
213
|
+
</p>
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<div id="map" style="width: 100%; height: 300px;"></div>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
<!-- 地図の埋め込み表示 -->
|
232
|
+
|
233
|
+
<div id="map_canvas" style="height: 300px; width: 550px;"></div>
|
234
|
+
|
235
|
+
<script
|
236
|
+
|
237
|
+
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAdZSnAW89DpXllrN7Hxb198lIbUAp2Hqg&libraries=places&callback=initMap"
|
238
|
+
|
239
|
+
defer>
|
240
|
+
|
241
|
+
>
|
242
|
+
|
243
|
+
</script>
|
244
|
+
|
245
|
+
<script th:src="@{/js/MapsJavaScriptCurrentLocationSearch.js}">
|
246
|
+
|
247
|
+
</script>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
252
|
+
|
205
253
|
|
206
254
|
|
207
|
-
<input id="pac-input" class="controls" type="text"
|
208
|
-
|
209
|
-
placeholder="Search Box">
|
210
|
-
|
211
|
-
</p>
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
<div id="map" style="width: 100%; height: 300px;"></div>
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
<!-- 地図の埋め込み表示 -->
|
230
|
-
|
231
|
-
<div id="map_canvas" style="height: 300px; width: 550px;"></div>
|
232
|
-
|
233
|
-
<script
|
234
|
-
|
235
|
-
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAdZSnAW89DpXllrN7Hxb198lIbUAp2Hqg&libraries=places&callback=initMap"
|
236
|
-
|
237
|
-
defer>
|
238
|
-
|
239
|
-
>
|
240
|
-
|
241
255
|
</script>
|
242
256
|
|
243
|
-
<script th:src="@{/js/MapsJavaScript
|
257
|
+
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
258
|
+
|
259
|
+
|
244
260
|
|
245
261
|
</script>
|
246
262
|
|
247
|
-
|
248
|
-
|
249
|
-
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
</script>
|
254
|
-
|
255
|
-
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
</script>
|
260
|
-
|
261
263
|
|
262
264
|
|
263
265
|
</div>
|
2
コードを見やすく編集しました。(画像からコードの挿入機能を使用して記述)
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,21 +14,323 @@
|
|
14
14
|
|
15
15
|
[javascriptファイル]
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
```javascript
|
20
|
+
|
21
|
+
function initAutocomplete() {
|
22
|
+
|
23
|
+
const map = new google.maps.Map(document.getElementById("map"), {
|
24
|
+
|
25
|
+
center: { lat: -33.8688, lng: 151.2195 },
|
26
|
+
|
27
|
+
zoom: 13,
|
28
|
+
|
29
|
+
mapTypeId: "roadmap",
|
30
|
+
|
31
|
+
});
|
32
|
+
|
33
|
+
// Create the search box and link it to the UI element.
|
34
|
+
|
35
|
+
const input = document.getElementById("pac-input");
|
36
|
+
|
37
|
+
const searchBox = new google.maps.places.SearchBox(input);
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
42
|
+
|
43
|
+
// Bias the SearchBox results towards current map's viewport.
|
44
|
+
|
45
|
+
map.addListener("bounds_changed", () => {
|
46
|
+
|
47
|
+
searchBox.setBounds(map.getBounds());
|
48
|
+
|
49
|
+
});
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
let markers = [];
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
// Listen for the event fired when the user selects a prediction and retrieve
|
58
|
+
|
59
|
+
// more details for that place.
|
60
|
+
|
61
|
+
searchBox.addListener("places_changed", () => {
|
62
|
+
|
63
|
+
const places = searchBox.getPlaces();
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
if (places.length == 0) {
|
68
|
+
|
17
|
-
|
69
|
+
return;
|
70
|
+
|
18
|
-
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
// Clear out the old markers.
|
76
|
+
|
77
|
+
markers.forEach((marker) => {
|
78
|
+
|
79
|
+
marker.setMap(null);
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
markers = [];
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
// For each place, get the icon, name and location.
|
88
|
+
|
89
|
+
const bounds = new google.maps.LatLngBounds();
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
places.forEach((place) => {
|
94
|
+
|
95
|
+
if (!place.geometry || !place.geometry.location) {
|
96
|
+
|
97
|
+
console.log("Returned place contains no geometry");
|
98
|
+
|
99
|
+
return;
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
const icon = {
|
106
|
+
|
107
|
+
url: place.icon,
|
108
|
+
|
109
|
+
size: new google.maps.Size(71, 71),
|
110
|
+
|
111
|
+
origin: new google.maps.Point(0, 0),
|
112
|
+
|
113
|
+
anchor: new google.maps.Point(17, 34),
|
114
|
+
|
115
|
+
scaledSize: new google.maps.Size(25, 25),
|
116
|
+
|
117
|
+
};
|
118
|
+
|
119
|
+
|
120
|
+
|
19
|
-
|
121
|
+
// Create a marker for each place.
|
122
|
+
|
20
|
-
|
123
|
+
markers.push(
|
124
|
+
|
125
|
+
new google.maps.Marker({
|
126
|
+
|
127
|
+
map,
|
128
|
+
|
21
|
-
|
129
|
+
icon,
|
130
|
+
|
22
|
-
|
131
|
+
title: place.name,
|
132
|
+
|
133
|
+
position: place.geometry.location,
|
134
|
+
|
135
|
+
})
|
136
|
+
|
137
|
+
);
|
138
|
+
|
139
|
+
if (place.geometry.viewport) {
|
140
|
+
|
23
|
-
|
141
|
+
// Only geocodes have viewport.
|
142
|
+
|
143
|
+
bounds.union(place.geometry.viewport);
|
144
|
+
|
145
|
+
} else {
|
146
|
+
|
147
|
+
bounds.extend(place.geometry.location);
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
});
|
152
|
+
|
153
|
+
map.fitBounds(bounds);
|
154
|
+
|
155
|
+
});
|
156
|
+
|
157
|
+
}
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
|
24
162
|
|
25
163
|
[htmlファイル]
|
26
164
|
|
27
|
-
|
165
|
+
```html
|
166
|
+
|
28
|
-
|
167
|
+
<!DOCTYPE html>
|
168
|
+
|
169
|
+
<html xmlns:th="http://www.thymeleaf.org"
|
170
|
+
|
171
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
172
|
+
|
173
|
+
<head>
|
174
|
+
|
175
|
+
<meta charset="UTF-8">
|
176
|
+
|
177
|
+
<title>Insert title here</title>
|
178
|
+
|
179
|
+
</head>
|
180
|
+
|
181
|
+
<body>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<!-- 地図を表示する div 要素 -->
|
186
|
+
|
187
|
+
<div id="map"></div>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<p>
|
196
|
+
|
197
|
+
<button onclick="getMyPlace()">現在位置を取得</button>
|
198
|
+
|
199
|
+
</p>
|
200
|
+
|
29
|
-
|
201
|
+
<div id="result"></div>
|
202
|
+
|
30
|
-
|
203
|
+
<p>
|
204
|
+
|
205
|
+
|
206
|
+
|
31
|
-
|
207
|
+
<input id="pac-input" class="controls" type="text"
|
208
|
+
|
209
|
+
placeholder="Search Box">
|
210
|
+
|
211
|
+
</p>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
<div id="map" style="width: 100%; height: 300px;"></div>
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
<!-- 地図の埋め込み表示 -->
|
230
|
+
|
231
|
+
<div id="map_canvas" style="height: 300px; width: 550px;"></div>
|
232
|
+
|
233
|
+
<script
|
234
|
+
|
235
|
+
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAdZSnAW89DpXllrN7Hxb198lIbUAp2Hqg&libraries=places&callback=initMap"
|
236
|
+
|
237
|
+
defer>
|
238
|
+
|
239
|
+
>
|
240
|
+
|
241
|
+
</script>
|
242
|
+
|
243
|
+
<script th:src="@{/js/MapsJavaScriptCurrentLocationSearch.js}">
|
244
|
+
|
245
|
+
</script>
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
</script>
|
254
|
+
|
255
|
+
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</script>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
</body>
|
268
|
+
|
269
|
+
</html>
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
```html
|
276
|
+
|
277
|
+
function getMyPlace() {
|
278
|
+
|
279
|
+
var output = document.getElementById("result");
|
280
|
+
|
281
|
+
if (!navigator.geolocation){//Geolocation apiがサポートされていない場合
|
282
|
+
|
283
|
+
output.innerHTML = "<p>Geolocationはあなたのブラウザーでサポートされておりません</p>";
|
284
|
+
|
285
|
+
return;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
function success(position) {
|
290
|
+
|
291
|
+
var latitude = position.coords.latitude;//緯度
|
292
|
+
|
293
|
+
var longitude = position.coords.longitude;//経度
|
294
|
+
|
295
|
+
output.innerHTML = '<p>緯度 ' + latitude + '° <br>経度 ' + longitude + '°</p>';
|
296
|
+
|
297
|
+
// 位置情報
|
298
|
+
|
299
|
+
var latlng = new google.maps.LatLng( latitude , longitude ) ;
|
300
|
+
|
301
|
+
// Google Mapsに書き出し
|
302
|
+
|
303
|
+
var map = new google.maps.Map( document.getElementById( 'map' ) , {
|
304
|
+
|
305
|
+
zoom: 15 ,// ズーム値
|
306
|
+
|
307
|
+
center: latlng ,// 中心座標
|
308
|
+
|
309
|
+
} ) ;
|
310
|
+
|
311
|
+
// マーカーの新規出力
|
312
|
+
|
313
|
+
new google.maps.Marker( {
|
314
|
+
|
315
|
+
map: map ,
|
316
|
+
|
317
|
+
position: latlng ,
|
318
|
+
|
319
|
+
} ) ;
|
320
|
+
|
321
|
+
};
|
322
|
+
|
323
|
+
function error() {
|
324
|
+
|
325
|
+
//エラーの場合
|
326
|
+
|
327
|
+
output.innerHTML = "座標位置を取得できません";
|
328
|
+
|
329
|
+
};
|
330
|
+
|
331
|
+
navigator.geolocation.getCurrentPosition(success, error);//成功と失敗を判断
|
332
|
+
|
333
|
+
```
|
32
334
|
|
33
335
|
[エラー情報]
|
34
336
|
|
1
コードを見やすく編集しました。(直書きから画像)
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,218 +14,24 @@
|
|
14
14
|
|
15
15
|
[javascriptファイル]
|
16
16
|
|
17
|
+
コード前半部分
|
17
18
|
|
19
|
+
![イメージ説明](54034fac7ff60cf87085331cd986c273.png)
|
18
20
|
|
19
|
-
|
21
|
+
コード後半部分
|
20
22
|
|
21
|
-
const map = new google.maps.Map(document.getElementById("map"), {
|
22
|
-
|
23
|
-
center: { lat: -33.8688, lng: 151.2195 },
|
24
|
-
|
25
|
-
zoom: 13,
|
26
|
-
|
27
|
-
mapTypeId: "roadmap",
|
28
|
-
|
29
|
-
});
|
30
|
-
|
31
|
-
// Create the search box and link it to the UI element.
|
32
|
-
|
33
|
-
const input = document.getElementById("pac-input");
|
34
|
-
|
35
|
-
const searchBox = new google.maps.places.SearchBox(input);
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
|
40
|
-
|
41
|
-
// Bias the SearchBox results towards current map's viewport.
|
42
|
-
|
43
|
-
map.addListener("bounds_changed", () => {
|
44
|
-
|
45
|
-
searchBox.setBounds(map.getBounds());
|
46
|
-
|
47
|
-
});
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
let markers = [];
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
// Listen for the event fired when the user selects a prediction and retrieve
|
56
|
-
|
57
|
-
// more details for that place.
|
58
|
-
|
59
|
-
searchBox.addListener("places_changed", () => {
|
60
|
-
|
61
|
-
const places = searchBox.getPlaces();
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
if (places.length == 0) {
|
66
|
-
|
67
|
-
return;
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
// Clear out the old markers.
|
74
|
-
|
75
|
-
markers.forEach((marker) => {
|
76
|
-
|
77
|
-
marker.setMap(null);
|
78
|
-
|
79
|
-
});
|
80
|
-
|
81
|
-
markers = [];
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
// For each place, get the icon, name and location.
|
86
|
-
|
87
|
-
const bounds = new google.maps.LatLngBounds();
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
places.forEach((place) => {
|
92
|
-
|
93
|
-
if (!place.geometry || !place.geometry.location) {
|
94
|
-
|
95
|
-
console.log("Returned place contains no geometry");
|
96
|
-
|
97
|
-
return;
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
const icon = {
|
104
|
-
|
105
|
-
url: place.icon,
|
106
|
-
|
107
|
-
size: new google.maps.Size(71, 71),
|
108
|
-
|
109
|
-
origin: new google.maps.Point(0, 0),
|
110
|
-
|
111
|
-
anchor: new google.maps.Point(17, 34),
|
112
|
-
|
113
|
-
scaledSize: new google.maps.Size(25, 25),
|
114
|
-
|
115
|
-
};
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
23
|
+
![イメージ説明](a466ef24357c6d6265f22aad20cd3d9c.png)
|
120
|
-
|
121
|
-
markers.push(
|
122
|
-
|
123
|
-
new google.maps.Marker({
|
124
|
-
|
125
|
-
map,
|
126
|
-
|
127
|
-
icon,
|
128
|
-
|
129
|
-
title: place.name,
|
130
|
-
|
131
|
-
position: place.geometry.location,
|
132
|
-
|
133
|
-
})
|
134
|
-
|
135
|
-
);
|
136
|
-
|
137
|
-
if (place.geometry.viewport) {
|
138
|
-
|
139
|
-
// Only geocodes have viewport.
|
140
|
-
|
141
|
-
bounds.union(place.geometry.viewport);
|
142
|
-
|
143
|
-
} else {
|
144
|
-
|
145
|
-
bounds.extend(place.geometry.location);
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
});
|
150
|
-
|
151
|
-
map.fitBounds(bounds);
|
152
|
-
|
153
|
-
});
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
24
|
|
159
25
|
[htmlファイル]
|
160
26
|
|
161
27
|
|
162
28
|
|
163
|
-
<!-- 地図を表示する div 要素 -->
|
164
|
-
|
165
|
-
|
29
|
+
![イメージ説明](59dc591483d829a71ff7c73f457edb27.png)
|
166
|
-
|
167
|
-
|
168
30
|
|
169
31
|
|
170
32
|
|
33
|
+
[エラー情報]
|
171
34
|
|
35
|
+
検索ボックスに入力してエンターを押すと公式サイトのサンプル上ではちゃんと動作するのですが、
|
172
36
|
|
173
|
-
<p>
|
174
|
-
|
175
|
-
<button onclick="getMyPlace()">現在位置を取得</button>
|
176
|
-
|
177
|
-
</p>
|
178
|
-
|
179
|
-
<div id="result"></div>
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
<!-- このinputタグが検索ボックス用 -->
|
184
|
-
|
185
|
-
<input
|
186
|
-
|
187
|
-
id="pac-input"
|
188
|
-
|
189
|
-
class="controls"
|
190
|
-
|
191
|
-
type="text"
|
192
|
-
|
193
|
-
|
37
|
+
私の場合は何も起きず、開発ツールのコンソールにも何も表示されていませんでした。
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
<div id="map" style="width: 100%; height: 300px;"></div>
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
<!-- 地図の埋め込み表示 -->
|
212
|
-
|
213
|
-
<div id="map_canvas" style="height: 300px; width: 550px;"></div>
|
214
|
-
|
215
|
-
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAdZSnAW89DpXllrN7Hxb198lIbUAp2Hqg&libraries=places&callback=initMap" defer>></script>
|
216
|
-
|
217
|
-
<script th:src="@{/js/MapsJavaScriptCurrentLocationSearch.js}">
|
218
|
-
|
219
|
-
</script>
|
220
|
-
|
221
|
-
<script th:src="@{/js/MapsJavaScriptGetAPI.js}">
|
222
|
-
|
223
|
-
</script>
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
<!-- 検索ボックスのjsファイル名-->
|
228
|
-
|
229
|
-
<script th:src="@{/js/MapsJavaScriptApiSearchBox.js}">
|
230
|
-
|
231
|
-
</script>
|