Bing 地图 V8 信息框导致错误

Bing Map V8 Infobox causing error

我正在尝试将 Bing Map V7 迁移到 V8,同时我遇到了显示信息框的问题,显示信息框后 Map SDK 出现错误。 来自应用程序的代码片段:

        function DisplayLoc(e) {
                var map = null;
                var pinInfobox = null;
                var pinInfoBox; // the pop up info box
                var infoboxLayer = new Microsoft.Maps.EntityCollection();
                var pinLayer = new Microsoft.Maps.EntityCollection();
                var pins = statewithcities;
                map = new 
               Microsoft.Maps.Map(document.getElementById('bing_map'), {
                    mapTypeId: Microsoft.Maps.MapTypeId.road,
                    showDashboard: false,
                    enableSearchLogo: false,
                    enableClickableLogo: false,
                    showMapTypeSelector: false,
                    showScalebar: false,
                    disablePanning: false,
                    disableZooming: false,
                    showBreadcrumb: false,
                    disableBirdseye: true,
                    showCopyright: false,
                    credentials: mapID
                });
                 pinInfobox = new Microsoft.Maps.Infobox(new 
                  Microsoft.Maps.Location(0, 0), {
                    visible: false,
                    titleClickHandler: InfoboxHandler
                });
                infoboxLayer.push(pinInfobox);
                $.each(pins, function(index, pin) {
                 var pinLocation = new Microsoft.Maps.Location(
                 pin.latitude, pin.longitude)
                   NewPin.metadata.Title = pin.zipCode; 
                    NewPin.metadata.Id = pin.state;
                    NewPin.metadata.Description = "test";
                    pinLayer.push(NewPin); // add pushpin to pinLayer
           Microsoft.Maps.Events.addHandler(NewPin, 'click',displayInfobox);
                    map.entities.push(NewPin);
                });
                map.entities.push(pinInfobox);
               function displayInfobox(e) {
                if(e.target.metadata){
                  pinInfobox.setOptions({
                        id: e.target.metadataId,
                        title: e.target.metadata.Title,
                        description: e.target.metadata.Description,
                        visible: true,
                        offset: new Microsoft.Maps.Point(0, 0),
                        location:e.target.getLocation()
                    });
                }
              }

请检查并帮助我,因为在遵循 Bing 文档后我不确定错误在哪里。

删除以下代码行:

infoboxLayer.push(pinInfobox);

map.entities.push(pinInfobox);

在创建信息框后添加以下代码行。:

pinInfobox.setMap(map);