AngularJs - GoogleMap:由于计时器没有定义插件?

时间:2017-01-13 16:43:53

标签: javascript angularjs timeout cordova-plugins

所以我有android的插件版本1.4.0。 每个工作第一次加载应用程序后,#cord; cordova运行android" 当我关闭并重新打开应用程序时,我有白屏和日志:

ReferenceError: plugin is not defined
    at map.js:33
    at angular.js:18744
    at completeOutstandingRequest (angular.js:5804)
    at angular.js:6081
(anonymous) @ angular.js:13236

我的map.js我初始化并使用地图

$timeout(function () {
            var div = document.getElementById("map_canvas");
            var ToulousePos = new plugin.google.maps.LatLng(43.6040488, 1.4430474000000686);
            var map = plugin.google.maps.Map.getMap(div, {
                'controls': {
                    'compass': false,
                    'myLocationButton': true,
                    'indoorPicker': false,
                    'zoom': false
                },
...code of the map...
, 1000);

1 个答案:

答案 0 :(得分:0)

我在devideReady上添加了一个add事件,所以它在正确的时间初始化:

document.addEventListener(“deviceready”,onDeviceReady,false);

function onDeviceReady(){     //现在可以安全地使用设备API     你的功能 }