Bing Maps API v8

老子叫甜甜 提交于 2020-01-17 06:40:26

问题


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

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?).


回答1:


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.



来源:https://stackoverflow.com/questions/44061241/bing-maps-api-v8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!