求助Js获取GPS问题。

做了一个获取GPS地址的功能,在编辑器里运行时,浏览器会正确提示弹出是否同意获取地址。但是打出webmoblie包并部署到服务器之后访问,浏览器不会提示权限,代码直接返回无权限错误(PERMISSION_DENIED)。。另外ios内用safari直接返回POSITION_UNAVAILABLE。。
附上代码:
getLocalGPS:function(){
var self = this;
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){self.getGPSSuccess(position);},
function(error){self.getGPSError(error);},
{enableHighAccuracy : true,timeout : 5000,maximumAge : 3000});
}else{
this.TestLabel.string = “browser not support”
}
},

getGPSSuccess:function(position){
    var coords = position.coords;
    this.TestLabel.string = "|" + coords.latitude + "||||" + coords.longitude + "|";
},
getGPSError:function(error){
    var errorstring = "";
    switch(error.code) {  
        case error.TIMEOUT:  
            errorstring = "A timeout occured! Please try again!";  
            break;  
        case error.POSITION_UNAVAILABLE:  
            errorstring = 'We can\'t detect your location. Sorry!';  
            break;  
        case error.PERMISSION_DENIED:  
            errorstring = 'Please allow geolocation access for this to work.';  
            break;  
        case error.UNKNOWN_ERROR:  
            errorstring = 'An unknown error occured!';  
            break; 
    }
    this.TestLabel.string = errorstring;
},