2017-08-03 9 views
0

Bing Map V7をV8に移行しようとしていますが、インフォボックスを表示した後、Map SDKにエラーが発生しています。アプリケーションから コードスニペット:Bing Map V8 Infoboxでエラーが発生しました

 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のマニュアルに従った後でどこかわからないとして私を助けてください。

答えて

1

は、次のコード行を削除します。

infoboxLayer.push(pinInfobox); 

map.entities.push(pinInfobox); 

は、インフォボックスを作成した後、次のコード行以下を追加します。:回答を

pinInfobox.setMap(map); 
+0

おかげで、今では正常に動作しますがインフォれますあなたがそれを手伝ってもらえますか? – poojagupta

+0

オフセットを調整してみてください:新しいMicrosoft.Maps.Point(0、0)、 ' – rbrundritt

関連する問題