0
我目前正在學習react-native,我正在研究一個使用地理定位來查找和更新我當前位置的應用程序,並且正在關注該教程以及教程我必須使用超時和maximumAge選項的屬性。React-Native什麼是地理位置中的超時和maximumAge
navigator.geolocation.getCurrentPosition((pozitie)=>{
var lat = parseFloat(position.coords.latitude)
var long = parseFloat(position.coords.longitude)
// create an object with the current position taken from the geolocation chip
var initialLocation = {
latitude = lat,
longitude = long,
// Delta is the viewing angle on the location of the user
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
// Now we are seting initial position to the initial location
this.setState({initialPositionOnTheMap: initialLocation})
// we set the marker to the initial location and then the display follows the marker
// by using the initialLocaiton object that will receive the users current location
this.setState({positionOfTheMarker: initialLocation})
},
// make a function call if an error happens
// we make an allert that parses the error message
(error) => alert(JSON.stringify(error)),
// propertie
{enableHighAccuracy: true, timeout: 2000, maximumAge: 1000})
,但它並不能說明什麼呢超時和maximumAge意思,爲什麼我們使用它們。
我知道這些選項用於react-native提供的兩個方法:getCurrentPosition(調用最新位置的回調)和watchPosition(每當位置發生變化時調用回調)但我不明白是什麼他們正在做着。
這是我迄今爲止發現的最好的描述[來自Mozilla網站](https://developer.mozilla。組織/ EN-US /文檔/網絡/ API/PositionOptions) – Deepank