0
我使用的是HTML5地理位置,並希望存儲的緯度和經度爲兩個獨立的文本框,而不是屏幕存儲javascript變量成HTML文本框中
下面就被簡單地顯示是代碼:
Current Location: <BR>
<button onclick="getLocation()">Locate</button>
<p id="demo"></p>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
}
</script>
嗯是的,但你也可以生成文本框,如果他們不存在 – 2015-02-11 01:04:19
@DustinPoissant請參閱我的答案的第二部分。 – Hydrothermal 2015-02-11 01:04:40