2017-01-13 17 views
1

私のビン地図は情報ボックスをロードしませんでした。 私はレンダリングされた位置のためにプッシュピンを作成する配列を持っています。 コンソールのメッセージが正しく表示されているかどうかを確認するために、コンソールのメッセージを追加しました。オフセット/アンカーがインフォボックスが表示されていないことと関係があるかどうか疑問に思っていました。誰かがここで私を助けることができる? Bing Mapsの情報ボックスが表示されません - setMapはコンソールの関数エラーではありません

var arrPins = []; 
var arrPinCenter = []; 
//Generating Pins for multiple locations with Lat,Long 
for (var locNum = 0; locNum <= arrLocInfoRec.length - 1; locNum++) { 
    try { 
      arrLLAdder = arrLocInfoRec[locNum].split("`"); 
      if (arrLLAdder.length >= 13) { 
       arrPinCenter[locNum] = new Microsoft.Maps.Location(parseFloat(arrLLAdder[11]), parseFloat(arrLLAdder[12])); 
       arrPinCenter[locNum] = new Microsoft.Maps.Location(parseFloat(arrLLAdder[11]), parseFloat(arrLLAdder[12])); 
       arrPins[locNum] = new Microsoft.Maps.Pushpin(
        arrPinCenter[locNum], {                         
       text: arrLLAdder[8] ,                                        icon: 'https://www.bingmapsportal.com/Content/images/poi_custom.png',                         anchor: new Microsoft.Maps.Point(12, 39) 
                        } 
var adder = arrLLAdder[2] + '\r\n' + arrLLAdder[4] + '\r\n' + arrLLAdder[6] + arrLLAdder[9] + "\r\n" + arrLLAdder[1] 
    // Create the infobox for the pushpin 
arrPinInfobox[locNum] = new Microsoft.Maps.Infobox(arrPins[locNum].getLocation(), 
     { width: 350, 
      height: 100, 
      title: arrLLAdder[5], 
      description: adder, 
      offset: new Microsoft.Maps.Point(-3,13)`enter code here` 
     }); 
// Add handler for the pushpin click event. 
Microsoft.Maps.Events.addHandler(arrPins[locNum], 'click', displayInfobox); 
    } 

else { 
    console.log("Invalid Data: arrLocInfoRec[" + locNum + "] = \"" + arrLocInfoRec[locNum] + "\""); 
         }`enter code here` 
        } catch (e) { 
         console.log(e.message + "\r\n" + arrLocInfoRec[locNum]); 
        } 
       } 
// Hide the infobox when the map is moved. 
// Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);  
// Add the Push Pins and InfoBox to the map all at once 

     if(arrPins.length > 0) { 
        map.entities.push(arrPins); //[locNum] 
        arrPinInfobox.setMap(map); 

//I get a console error here for the setMap function 
// see error below 
        //map.entities.push(arrPinInfobox); 
        //map.entities.push(InfoBoxEntity); 
       } 


      } 

Uncaught TypeError: arrPinInfobox.setMap is not a function at GetMap (68A611D186DE4DC991773CAED323DA31.ashx:135) at Object.Microsoft.Maps.notifyMapReadyForBootstrap (www.bing.com/mapspreview/sdk/mapcontrol?branch=release&callback=GetMap:14) at www.bing.com/rms/SDKPlugin/jc,nj/9ac8b1b9/4153aba0.js?//bu=rms+answers+MapsSD…leLayerMapsTilePrimerSDKMapPointCompressionSDKPluginEndAnonymousEnd:1 at www.bing.com/rms/SDKPlugin/jc,nj/9ac8b1b9/4153aba0.js?//bu=rms+answers+MapsSD…//leLayerMapsTilePrimerSDKMapPointCompressionSDKPluginEndAnonymousEnd:1

は、私はあなたのコードにいくつかのブレークポイントを追加し、それをステップインフォボックス

  function displayInfobox(e) { 
        //map.entities.push(arrPinInfobox); 
       console.log("DisplayBox"); 
       for(var i in arrPinInfobox) 
        arrPinInfobox[i].setOptions({ visible: true }); 
       arrPinInfobox[parseInt(e.target.getText()) - 1].setOptions({ visible: true }); 
      } 

答えて

0

を表示するには、以下のコードを使用します。あなたのコードはちょっと面倒ですが、setMapのコード行になる頃には、try文の内部で作成され、決して作成されなかった可能性があるので、infoboxは決して作成されませんでした。

つまり、パフォーマンスを向上させるために、単一のInfoboxを使用することを強くお勧めします。このコードサンプルを見てみましょう:https://msdn.microsoft.com/en-us/library/mt750274.aspx

+0

Thannks!これは動作します! – user7416176

関連する問題