質問編集履歴
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
## やったこと
|
5
5
|
[こちら](https://codeaid.jp/gas-html/)の記事を参考に<body>と<script>の間に`<?!= HtmlService.createHtmlOutputFromFile('index').getContent(); ?>`を追記しましたがダメでした。[Geolocation API](https://www.w3.org/TR/geolocation/)はGASでは使えないということなのでしょうか?gsファイルでhtmlファイルのインポートに失敗しているのか、geoFindUser()の書き方が違うのか判断しかねました。どなたか知見のある方、ぜひご教授よろしくお願いします。
|
6
6
|
|
7
|
-

|
8
8
|
|
9
9
|
コード.gs
|
10
10
|
```
|
1
っd
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
## 現状
|
2
|
-
以下のコードを実行すると画像のようになってしまい、
|
2
|
+
以下のコードを実行すると画像のようになってしまい、現在地の緯度と経度が表示されません。
|
3
3
|
|
4
4
|
## やったこと
|
5
|
-
[こちら](https://codeaid.jp/gas-html/)の記事を参考に<body>と<script>の間に`<?!= HtmlService.createHtmlOutputFromFile('index').getContent(); ?>`を追記しましたがダメでした。どなたか知見のある方、ご教授よろしくお願いします。
|
5
|
+
[こちら](https://codeaid.jp/gas-html/)の記事を参考に<body>と<script>の間に`<?!= HtmlService.createHtmlOutputFromFile('index').getContent(); ?>`を追記しましたがダメでした。[Geolocation API](https://www.w3.org/TR/geolocation/)はGASでは使えないということなのでしょうか?gsファイルでhtmlファイルのインポートに失敗しているのか、geoFindUser()の書き方が違うのか判断しかねました。どなたか知見のある方、ぜひご教授よろしくお願いします。
|
6
6
|
|
7
7
|

|
8
8
|
|
@@ -22,7 +22,18 @@
|
|
22
22
|
</head>
|
23
23
|
<body>
|
24
24
|
<script>
|
25
|
+
function geoFindUser() {
|
26
|
+
//getCurrentPositionメソッドで現在地を取得
|
27
|
+
navigator.geolocation.getCurrentPosition(
|
28
|
+
//現在地の取得に成功した場合の処理
|
29
|
+
function(position) {
|
30
|
+
//データを変数にして整理(position.coords.latitude/longitudeが座標)
|
31
|
+
var lat = position.coords.latitude;
|
32
|
+
var lng = position.coords.longitude;
|
25
|
-
|
33
|
+
console.log(lat,lng);
|
34
|
+
}
|
35
|
+
)
|
36
|
+
}
|
26
37
|
</script>
|
27
38
|
</body>
|
28
39
|
</html>
|