2013-06-27 58 views
0

在Android(HTC Incredible S设备和Android虚拟设备)上,当我导航到我的“我在哪里?”页:worklight v6.0繁忙指标问题与Android

  1. init和显示繁忙指示“检查你的位置”
  2. 负荷谷歌地图API
  3. 地理定位和显示谷歌地图
  4. 隐藏的忙指示

我第一次去到那个页面,忙指示符从不显示。

第二次我去那个页面,有一个“加载”繁忙指标冻结我的应用程序。我必须杀死应用程序之外的进程。

当我删除忙线指示灯的代码行时,我的应用程序工作正常。

这里有繁忙指示冻结代码:

// Geolocation of collaborators 
var map; 
function initialize() { 
    var busyInd = new WL.BusyIndicator('content', {text : 'Checking your location...'}); 
    busyInd.show(); 
    console.log('Initializing google Maps'); 

     // Try HTML5 geolocation 
    if(navigator.geolocation) { 
     var options = { timeout: 30000, enableHighAccuracy: true }; 

     navigator.geolocation.getCurrentPosition(function(position) { 
     var mapOptions = { 
         zoom: 6, 
         streetViewControl: false, 
         mapTypeControl: false, 
         mapTypeId: google.maps.MapTypeId.ROADMAP 
        }; 
     map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); 

     var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 
     var infowindow = new google.maps.InfoWindow({ 
      map: map, 
      position: pos, 
      content: 'You are here', 
      maxWidth: 60 
     }); 
     map.setCenter(pos); 
     }, function(error) { 
      console.log('Hiding busy indicator when geolocation failed'); 
    busyInd.hide(); 
     handleNoGeowith location(true, error); 
     }, options); 
    } else { 
     // Browser doesn't support Geolocation 
     handleNoGeolocation(false); 
     busyInd.hide(); 
    } 
busyInd.hide(); 
} 

function handleNoGeolocation(errorFlag, error) { 
    console.log('Handle no geolocation message error'); 
var content; 
if (errorFlag) { 
    var errorCode = error.code; 
    var errorMsg = error.message; 
    content = 'Error: The Geolocation service failed. Code: '+errorCode+', Message: '+errorMsg; 
} else { 
    content = 'Error: Your browser doesn\'t support geolocation.'; 
} 

alert(content); 
} 
var isGMapAPILoaded = false; 
function loadGoogleMaps() { 
    console.log('initializing google maps api'); 
    if(isGMapAPILoaded){ 
     // Google Maps API already loaded 
     console.log('Google Maps API already loaded, call initialize'); 
     initialize(); 
    } else { 
     var script = document.createElement("script"); 
     script.type = "text/javascript"; 
     script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize"; 
     document.body.appendChild(script); 
     isGMapAPILoaded = true; 
     console.log('Google Maps API loaded with success'); 
    } 
} 

回答

0

您是否尝试过在全球创建的忙指示对象,而不是此特定函数内(我也不懂这个“初始化”功能的范围...我认为这是特定于应用程序的代码)。

在您的应用程序的.js文件(yourProject \ APPS \ yourApp \ COMMON \ yourApp.js)做这样的事情:

var busy; 

function wlCommonInit() { 

    busy = new WL.BusyIndicator(); 

然后,在你initialize()功能,在需要时调用busy.show()busy.hide()