必应Maps API v8 [英] Bing Maps API v8

查看:64
本文介绍了必应Maps API v8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将东西从v7迁移到v8 Bing Maps API.

I'm moving stuff from the v7 to the v8 Bing Maps API.

我正在使用异步加载和回调来触发地图.

I'm using the async load and a callback to trigger the map.

但是,在我的站点"页面中,出现以下错误(在一个简单的测试页面中,几乎可以使用相同的代码来正常工作):

However, in my "site" page I'm getting the following error (in a simple test page it all works fine with nearly the identical code):

mapcontrol?callback=loadMap:12 Uncaught TypeError: n.open is not a function
at Object.send (mapcontrol?callback=loadMap:12)
at y (mapcontrol?callback=loadMap:12)
at v (mapcontrol?callback=loadMap:12)
at i.c [as resolve] (mapcontrol?callback=loadMap:12)
at f (mapcontrol?callback=loadMap:12)
at n.p [as downloadDependency] (mapcontrol?callback=loadMap:12)
at t.d [as downloadDependency] (mapcontrol?callback=loadMap:12)
at mapcontrol?callback=loadMap:14
at mapcontrol?callback=loadMap:15

有人知道这意味着什么吗?我猜想在地图加载时该回调不可用,但是我可以从devtools控制台调用该回调并运行它(但似乎没有找到Bing Maps方法,这很奇怪-看起来几乎像一个奇怪的范围问题?).

Does anyone know what this means? I'm guessing that the callback isn't available when the map loads, but I can call the callback from devtools console and it runs it (but doesn't seem to find the Bing Maps methods, which is weird-- seems almost like an odd scope problem?).

推荐答案

尝试在其余代码后添加地图脚本.在加载地图脚本时使用异步延迟时,只要有可用的地图代码,它将首先进行回调,如果缓存了该代码,则该代码将位于其下一页中的其他任何内容之前.

Try adding the map script after the rest of your code. When using async defer when loading the map script, it will first the callback as soon as the map code is available which, if cached, would be before anything else in the page below it.

这篇关于必应Maps API v8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆