1
這是如何工作的?請提供關於如何從頭開始構建此功能的詳細答案。Milo.com使用什麼技術來實現「定位我」功能?
這是如何工作的?請提供關於如何從頭開始構建此功能的詳細答案。Milo.com使用什麼技術來實現「定位我」功能?
調查HTML5地理位置。看到這一點: http://merged.ca/iphone/html5-geolocation/
按照該代碼,您要使用navigator.geolocation檢索適當的位置:
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(
function (position) {
// Did we get the position correctly?
// alert (position.coords.latitude);
// To see everything available in the position.coords array:
// for (key in position.coords) {alert(key)}
mapServiceProvider(position.coords.latitude,position.coords.longitude);
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
}
);
}
}
else // finish the error checking if the client is not compliant with the spec