【发布时间】:2010-08-23 15:14:16
【问题描述】:
navigator.geolocation.getCurrentPosition 如果我通过无线连接到互联网,则返回大约纬度/经度信息。但是,通过网络电缆连接时方法调用失败。这是设计使然还是我遗漏了什么?下面是示例 html 页面,我正在使用 Chrome 5 对其进行测试。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Geocode Test</title>
<script type="text/javascript">
function getGeoLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
alert(position);
},
function () {
alert("oops");
});
}
}
</script>
</head>
<body>
<h1>Get Current Location</h1>
<button id='btnGetLocation' onclick='getGeoLocation()'>Get Current Location</button>
</body>
</html>
TIA
【问题讨论】:
-
你说的是iPhone模拟器吗?您需要在问题中提供更多详细信息,并相应地更新您的标签,以便人们了解您的问题。
-
@Jason,添加了示例 html 页面。我没有使用 iPhone 模拟器。
-
抱歉,我的标签编辑过激了。
标签: geolocation