获取用户坐标的html,html5获取用户地理位置
可以通過H5的內置程序獲得:
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
navigator.geolocation.getCurrentPosition(
displayPosition,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
}
else {
alert("Geolocation is not supported by this browser");
}
function displayPosition(position) {
alert("Latitude: " + position.coords.latitude + ", Longitude: " + position.coords.longitude);
}
function displayError(error) {
var errors = {
1: '申請拒絕',
2: '無法精確匹配地址',
3: '請求超時'
};
alert("錯誤: " + errors[error.code]);
}
瀏覽器支持:
Firefox 3.5+
Chrome 5.0+
Safari 5.0+
Opera 10.60+
Internet Explorer 9.0+
手機支持:
Android 2.0+
iPhone 3.0+
Opera Mobile 10.1+
Symbian (S60 3rd & 5th generation)
Blackberry OS 6
總結
以上是生活随笔為你收集整理的获取用户坐标的html,html5获取用户地理位置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 从mysql到大数据(二)--数据库的认
- 下一篇: 小鸡模拟器 android,安卓小鸡模拟