所以我使用navigator.geolocation.getCurrentPosition jammy有一个相当简单的JS.
$(document).ready(function(){
$("#business-locate, #people-locate").click(function() {
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
});
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
function foundLocation(position) {
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var userLocation = lat + ', ' + lon;
$("#business-current-location, #people-current-location").remove();
$("#Near-Me")
.watermark("Current Location")
.after("<input type='hidden' name='business-current-location' id='business-current-location' value='"+userLocation+"' />");
$("#people-Near-Me")
.watermark("Current Location")
.after("<input type='hidden' name='people-current-location' id='people-current-location' value='"+userLocation+"' />");
}
function noLocation() {
$("#Near-Me").watermark("Could not find location");
$("#people-Near-Me").watermark("Could not find location");
}
})//end DocReady
Run Code Online (Sandbox Code Playgroud)
基本上这里发生的是我们得到当前位置,如果得到的话,两个"水印"被放置在两个字段中,表示"当前位置",两个隐藏字段用lat-long数据作为它们的值(它们被删除)在一开始所以他们不会每次都重复).还有两个按钮,它们具有与之相关的点击功能,可以执行相同的操作.不幸的是,每三次左右,它都有效.这有什么问题???
现在,谷歌地图可以借助Firefox在街道精确度上精确定位我的位置.
我知道这是HTML 5兼容浏览器的一个新功能,并且通过使用连接的WiFi网络的某种功能来获取位置(我希望我没有做出任何愚蠢的假设).
我打算知道整个过程是如何工作的:
提前致谢!
iPhone通过以下调用支持移动Safari中的地理位置:
navigator.geolocation.getCurrentPosition(
function(pos){
var lat = pos.coords.latitude;
var long = pos.coords.longitude;
},
function(){
/* Handler if location could not be found */
}
);
Run Code Online (Sandbox Code Playgroud)
我想建立一个包含以下其中一项的良好设备列表:
我只熟悉自己的设备,所以到目前为止这是我的列表:
?
Blackberry,Android手机等的支持程度如何?