0

クリック イベントではなく、起動時に自動的に読み込まれる複数のインフォボックスを bing マップに追加したいと考えています。プッシュピンが 3 つあるとします。たとえば、1 番目のインフォボックスにはジェームス、2 番目のマーク、3 番目などが含まれます。今のところ、ループに入れて追加しようとすると、常に最後の値を取ります

 for (var i = 0; i < json.length; i++) {
                          var pinInfoBox;  //the pop up info box
                          var infoboxLayer = new Microsoft.Maps.EntityCollection();
                          var pinLayer = new Microsoft.Maps.EntityCollection();
                          var loc = jsonData.location[i];
                           var pushpinOptions = {icon: 'xxx.png', width: 80, height: 80, offset: new Microsoft.Maps.Point(0, 15)};
                         var infoboxOptions = {showCloseButton: true, visible:false };
                          pinInfobox = new Microsoft.Maps.Infobox(map.getCenter(), infoboxOptions );
                           pinInfobox.setHtmlContent('<div class="arrow_box"><div class="content" id="content">'+loc.name+'</div></div>'); //here the name should keep changing
                          infoboxLayer.push(pinInfobox);
                          var pin = new Microsoft.Maps.Pushpin(latLon,pushpinOptions);
                           pinLayer.push(pin); //add pushpin to pinLayer
                          Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox); //here instead of click event i want the infobox to display automatically on startup
                          map.entities.push(pinLayer);
                          map.entities.push(infoboxLayer);
           }

           function displayInfobox(e) {

        pinInfobox.setOptions({title: e.target.Title, description: e.target.Description,                  visible:true, offset: new Microsoft.Maps.Point(-50,90)});
      pinInfobox.setLocation(e.target.getLocation());
          }
4

1 に答える 1