Javascript 不推荐使用jsapi加载程序加载Maps API
最近,我在控制台日志中看到以下消息: 不推荐使用jsapi加载程序加载Maps API 这是导致它的代码:Javascript 不推荐使用jsapi加载程序加载Maps API,javascript,google-maps-api-3,google-api,deprecation-warning,Javascript,Google Maps Api 3,Google Api,Deprecation Warning,最近,我在控制台日志中看到以下消息: 不推荐使用jsapi加载程序加载Maps API 这是导致它的代码: connected: function() { ... }, initComponent: function() { var me = this; google.load('maps', '3', { other_params: 'key=YOUR_API_KEY', callback : me.connected });
connected: function() {
...
},
initComponent: function() {
var me = this;
google.load('maps', '3', {
other_params: 'key=YOUR_API_KEY',
callback : me.connected
});
...
}
静态加载对我来说这不是一个真正的选项,因为callback=connected
将调用window.connected()
,而不是me.connected()
:
调用本地作用域时,除了
google.load()
,还有什么替代方法?位于的文档仅提供静态加载。在全局范围中添加此功能时:
window.connected = function() {
console.log("Maps API connected");
};
这表明它早在应用程序启动之前就已连接:
Maps API connected
Util.js:747 [V] the Application was launched.
所以这可能不是问题。我所要做的就是把它叫做afterender
listeners: {
afterrender: function() {
appdata.items.panel.Maps.connected();
}
},
listeners: {
afterrender: function() {
appdata.items.panel.Maps.connected();
}
},