首页 > 解决方案 > Microsoft.Maps.SDKMap 未定义,在 BingMaps V8 中创建对象时

问题描述

创建 bingmap 实例时,SDKMap 未定义。以下代码中是否缺少任何凭据?

function GetBingMap(){

            var vcredentials = "<%=this.credentialKey%>" //credential Key
            var vzoomLevel = Number("<%=this.zoom%>");    //Zoom Level  
            
            // Create the Map instance
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), //div map load
            {
                credentials: vcredentials, //credential
                zoom: vzoomLevel, //zoom level
                showZoomButtons: false, // enable Zoom Buttons
                showLocateMeButton: false, // show Locate me button
                showMapTypeSelector: false,//enable Map type selector
                showScalebar: false,//enable scale bar
                showTermsLink: false//enable terms link
            });
            this.map= map;

标签: javascriptbing-maps

解决方案


确保在调用 GetBingMap 函数之前已加载 Bing 地图源代码。在您的代码尝试创建地图实例之前,它听起来还没有完全加载。如果您在脚本标记的脚本引用中使用 async/defer,请将其删除。


推荐阅读