问题
I am working on Ionic App and want to fix issue for Geolocation Watch Position. I want to get data after every 1 minutes not after 5 sec. My code is as following,
var opti = { enableHighAccuracy: false, timeout:60000, maximumAge: 0 };
navigator.geolocation.watchPosition(success_loc, error_loc, opti);
I am using timeout 60000 for giving result after 1 minutes but it is giving result in 5 sec(default time). Need help to fix this problem.
回答1:
You need to set the maximumAge to 60000. As per the docs, the timeout option indicates the time allowed for obtaining the position. So, this is not what something you are interested. Instead, use the maximumAge. When the maximumAge is set to 60000, for one minute the cached position will be used instead of obtaining a new one.
来源:https://stackoverflow.com/questions/38585556/watchposition-time-out-in-geolocation