GPS가 연결되어 있지 않은 경우 위치를 반환 할 수있는 방법이 보장되지 않습니다.
캐시 된 위치를 대신 사용해 볼 수 있습니다. API 사양에서 다음을 참조하십시오.
// Request a position. We only accept cached positions, no matter what
// their age is. If the user agent does not have a cached position at
// all, it will immediately invoke the error callback.
navigator.geolocation.getCurrentPosition(successCallback,
errorCallback,
{maximumAge:Infinity, timeout:0});
function successCallback(position) {
// By setting the 'maximumAge' to Infinity, the position
// object is guaranteed to be a cached one.
// By using a 'timeout' of 0 milliseconds, if there is
// no cached position available at all, the user agent
// will immediately invoke the error callback with code
// TIMEOUT and will not initiate a new position
// acquisition process.
if (position.timestamp < freshness_threshold &&
position.coords.accuracy < accuracy_threshold) {
// The position is relatively fresh and accurate.
} else {
// The position is quite old and/or inaccurate.
}
}
function errorCallback(error) {
switch(error.code) {
case error.TIMEOUT:
// Quick fallback when no cached position exists at all.
doFallback();
// Acquire a new position object.
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
break;
case ... // treat the other error cases.
};
}
function doFallback() {
// No cached position available at all.
// Fallback to a default position.
}
PC에 GPS가 연결되어 있지 않은데 왜 위치를 얻을 수 있습니까? – fasisi
그리고 GPS가 내장 된 블랙 베리 전화가 있습니다. 휴대 전화의지도 응용 프로그램은 GPS에서 위치 정보를 가져올 수 있습니다. 그러나 웹 사이트는 입장을 얻을 수 없습니다. 문제가 무엇입니까? – fasisi
사양에 따르면 장치는 IP 주소를 포함하여 위치를 대략적으로 계산하는 여러 가지 방법을 사용할 수 있습니다. –