2017-01-13 6 views
1

빙지도가 정보 상자를로드하지 않습니다. 렌더링 된 위치에 대한 압핀을 만드는 배열이 있고 아래에 내가 사용하는 코드가 있습니다. 제대로 표시되는지 확인하기 위해 디스플레이의 콘솔 메시지를 추가했습니다. offset/anchor가 infobox가 표시되지 않는 것과 관련이 있는지 궁금합니다. 누군가 나를 도와 줄 수 있습니까? 빙지도 정보 상자가 표시되지 않습니다. - 콘솔에서 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