工作,我創建了以下兩個文件:地理位置不HtmlService
code.gs
function doGet() {
var html = HtmlService.createHtmlOutputFromFile('html.html');
return html;
}
中將Html.HTML
<html>
<body>
<p id="messaging">Click the button to get your coordinates:</p>
<button onclick="getLocation()">Where am I</button>
<script>
var message=document.getElementById("messaging");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
message.innerHTML="Geolocation is not supported.";
}
}
function showPosition(position) {
message.innerHTML="Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
當我致電發佈的網址,我收到了預期的消息和按鈕。點擊按鈕,我得到我的失敗消息「不支持地理定位」。如果我將html.html保存在一個文件中,並在瀏覽器中打開它,它會按預期工作。
任何想法?
感謝科瑞。 PS你知道我專注於'尚'。 :-) – Weehooey
沒有承諾,但我們正在努力添加內容 –
自原始請求以來的更新?任何想法,如果/當它的GeoLocation將在HtmlService中可用? – wivku