我有一个区域和经度/经度列表,我要求用户在他们访问我的网站时选择他们的位置.如果可能的话,我希望使用
HTML5的地理位置预先填充他们的位置,但我不确定最好的方法.网上似乎缺少教程,至少从我能找到的内容来看.有没有人这样做过?你知道一个好的教程/资源吗?
更新
如果我有一堆城市的坐标,我如何使用javascript来确定最近的位置?
解决方法
试试这个例子:
@H_502_10@window.onload = function(){
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(handleGetCurrentPosition,onError);
}
function handleGetCurrentPosition(location){
location.coords.latitude;
location.coords.longitude;
}
function onError(){...}
去这里进行更大的演示. http://od-eon.com/labs/geolocation/