geoLocation启用无页刷新? [英] geoLocation enabling without page-refresh?
问题描述
目前,如果GPS已关闭,(通知用户后),然后开启,我们必须刷新网页(实际上是 PhoneGap
p>
如何更新 GeoLocation
状态,而无需刷新页面/应用程序?
希望这有助于别人出去。我有同样的问题,尝试加载geoLocation通过Google Maps API在多页phonegap + JQM应用程序。 setInterval / setTimer没有工作。唯一的方法,我得到它的工作是做一个完全刷新也,kinda使应用程序看起来破碎。
onDeviceReady没有为我工作,因为地理位置没有调用index.html文件
我的解决方案不是在地理位置视图/页面加载时尝试调用地理位置。而是插入一个按钮来调用脚本:
< a href =#onclick =getLocation() data-role =button>获取我的位置< / a>
然后使用附加到getLocation()的Javascript调用geolocation API
function getLocation(){
navigator.geolocation.getCurrentPosition(onSuccess,onError,
{timeout:10000,enableHighAccuracy:true});
var lat;
var lng;
}
Currently, we have to refresh the web-page (actually PhoneGap
app) if the GPS was off and (after notifying the user) then turned-on.
How can we update the GeoLocation
status without the need to refresh the page/app ?
Hopefully this helps someone else out. I had the same issues with trying to load the geoLocation over Google Maps API in a multi page phonegap+JQM app. A setInterval/setTimer did not work as well. The only way i got it to work was doing a complete refresh also, kinda makes the app look broken.
onDeviceReady did not work for me either as geolocation was not called within index.html file
My solution was not to try to call geolocation when the geolocation view/page loads. Instead insert a button to call the script:
<a href="#" onclick="getLocation();" data-role="button">Get My Location</a>
Then call the geolocation API with Javascript attached to getLocation()
function getLocation() {
navigator.geolocation.getCurrentPosition(onSuccess ,onError,
{ timeout: 10000, enableHighAccuracy: true } );
var lat;
var lng;
}
这篇关于geoLocation启用无页刷新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!