我创建了一个脚本,它将使用地理定位库显示用户的位置,一切正常.我已经使用PhoneGap导出了这个HTML 5脚本,可以看到在Settings-> Location Services我的应用程序设置为On.所以我假设每次运行我的应用程序时都不会得到常规提示"....想用你当前的位置?" 选项不允许或确定.
我不想让人们每次打开我的应用程序时都单击"允许".应用程序是否没有使用"服务" - >"位置设置"中的设置?以下是简单的脚本:
<!DOCTYPE html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="apple-touch-icon-precomposed" href="custom_icon_precomposed.png"/>
<link rel="apple-touch-startup-image" href="apple-touch-icon-precomposed.png">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
<script>
jQuery(window).ready(function(){
jQuery("#btnInit").click(initiate_watchlocation);
jQuery("#btnStop").click(stop_watchlocation);
});
var watchProcess = null;
function initiate_watchlocation() {
if (watchProcess == null) {
watchProcess = navigator.geolocation.watchPosition(handle_geolocation_query, handle_errors, {enableHighAccuracy:true});
}
}
function stop_watchlocation() {
if (watchProcess != null)
{
navigator.geolocation.clearWatch(watchProcess);
watchProcess = null;
}
}
function handle_errors(error)
{
switch(error.code)
{
case …Run Code Online (Sandbox Code Playgroud) 我试图添加一个监听器,但它不会触发
plugins: [{
ptype: 'pullrefresh',
autoPaging: true,
listeners: {
'released': function(plugin,list){
// call the plugins processComplete method to hide the 'loading' indicator
/* your_store.on('load', plugin.processComplete, plugin, {single:true});
// do whatever needs to happen for reload
your_store.load();*/
alert('test');
}
}
}],
Run Code Online (Sandbox Code Playgroud)
我想要做的是有人在刷新事件被触发时拉出列表我们得到用户的纬度和经度并将值加载到商店中.我的问题是商店beforeload:事件没有正确的事件泡沫,因此它可以在它可以获得用户地理位置之前存储json调用.
My Store{
listeners: {
beforeload: function(){
console.log( 'me1' );
//call this to write to location services on device
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
console.log( 'me2' );
Rad.stores.games.getProxy().extraParams.lat = position.coords.latitude;
Rad.stores.games.getProxy().extraParams.long = position.coords.longitude;
});
}
console.log( 'me3' );
}
} …Run Code Online (Sandbox Code Playgroud)