例如我要使用geolocation的api,里面有getcurrentlocation方法,如何将外部定义的map传给successCallback内部?
var map = new googleMap
navigator.geolocation.watchPosition(successCallback,errorCallback,options);
function succesCallback(position){//这里position是默认的,我需要将外部定义的map引入,如果我加了新的传入参数会报错。
map.latitude = position.coords.latitude
map.longitude = position.coords.longitude
}
期待解答
怪我咯2017-04-10 15:13:36
var app = {
getGeoLoc : function (id) {
var self = this;
navigator.geolocation.getCurrentPosition(function(position) {
var myVar1, myVar2, myVar3;
self.foundLoc(position, self, myVar1, myVar2, myVar3)
}, this.noloc, { timeout : 3});
},
foundLoc : function(position, self, myVar1, myVar2, myVar3) {},
};