WatchPosition Time Out In Geolocation

三世轮回 提交于 2019-12-06 10:11:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!