我有一个欢迎/登录屏幕的应用程序,在您签名后,您将进入一个标签屏幕,其中有四个标签,第一个标签显示谷歌地图。
首次登录时,页面不会显示自己,但刷新页面时,地图显示正常,因为预计第一次执行。这种情况每次都会发生,但我只收到一个javascript错误。
Uncaught Error: can't load XRegExp twice in the same frame(anonymous function) @ xregexp-min.js:2
function initialize() {
var mapOptions = {
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById("map"),
mapOptions
);
var geocoder = new google.maps.Geocoder();
$scope.map = map;
$scope.centerOnMe();
}
google.maps.event.addDomListener(window, 'load', initialize);
$scope.centerOnMe = function() {
if(!$scope.map) {
return;
}
$scope.loading = $ionicLoading.show({
content: 'Getting current location...',
showBackdrop: false
});
// get user location
$cordovaGeolocation
.getCurrentPosition({
timeout:10000,
enableHighAccuracy:true
})
.then(function(position) {
$ionicLoading.hide();
// we found the position
$scope.map.setCenter(
new google.maps.LatLng(
position.coords.latitude,
position.coords.longitude
)
);
}, function(e) {
$ionicLoading.hide();
console.log(e);
alert("Uh oh, we can't find your position! Is your GPS enabled?\n\n" + e);
});
};
这是我用离子初始化替换google init后的最新javascript错误。我理解发生了什么,但我不知道我应该将该函数声明移动到哪里。我把它移到init里面,但它仍然没有用。我应该设置超时吗?
TypeError: $scope.loadLocations is not a function
at initialize (controllers.js:179)
at Object.ionic.Platform.ready (ionic.bundle.js:2120)
at new <anonymous> (controllers.js:182)
at invoke (ionic.bundle.js:12468)
at Object.instantiate (ionic.bundle.js:12476)
at ionic.bundle.js:16745
at IonicModule.controller.self.appendViewElement (ionic.bundle.js:47716)
at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.render (ionic.bundle.js:45973)
at Object.IonicModule.factory.ionicViewSwitcher.create.switcher.init (ionic.bundle.js:45893)
at IonicModule.controller.self.render (ionic.bundle.js:47590)