none
Bing maps Ajax control 7 , removing pushpin useing entitycollection removeAt property. RRS feed

  • Question

  • I have a ajax resultset which returns hotel details and those hotels are being shown on the bing map as pushpin,
    next to the map i have the hotel names with matching checkbox against each hotel and which is checked on first load.
    My requirement is as this- when i need to uncheck the checkbox and click on a updatemap link only the checkbox which is selected needs to be present on the map as pushpin and remaining should get erased. The removeAt does work for odd number's but not for even pushpins. I also noticed that the updatelink needs to be clicked three to four times to get proper result. Please help


    function AddPins(bUpdateInd)
    {
        var pinID;
       
        pinArray = null;
        pinArray = new Array(iHLIndexEnd - iHLIndexStart);
        for (var x = iHLIndexStart; x < iHLIndexEnd; x++)
        {
            var ckboxitem = "ckboxid" + x;
            if ((!document.getElementById(ckboxitem).disabled) && (document.getElementById(ckboxitem).checked))
             {
                pinID = x;
                var HtlName = HotelListNodeList[x].getAttribute('name');
                var HtlLat = HotelListNodeList[x].getAttribute('lat');
                var HtlLong = HotelListNodeList[x].getAttribute('long');
                var HtlAddrLine1 = HotelListNodeList[x].getAttribute('address1');
                var HtlAddrLine2 = HotelListNodeList[x].getAttribute('address2');
                var HtlPropertyType = HotelListNodeList[x].getAttribute('propertytypename');
                var HtlImageURL = HotelListNodeList[x].getAttribute('imageurl');
                if (x >= 100)
                    hotelnum = (x % 100) + 1;
                else
                    hotelnum = x + 1;
                var shotnum = String(hotelnum);
                var HotelPinImg = 'images\\pins\\' + GetIconAvailColor(x) + 'Circle' + shotnum + '.gif';
                loc[x] = new Microsoft.Maps.Location(HtlLat, HtlLong);
                var HotelIcon = HotelPinImg;
                var HtlPopup_Main = GetHotelPopup_Main(pinID, HtlName, HtlAddrLine1, HtlAddrLine2, HtlPropertyType, HtlImageURL);
                var dq = "'";
                //GetHotelPopup_Main(pinID,HtlName,HtlAddrLine1,HtlAddrLine2,HtlPropertyType,HtlImageURL);
                poptions = dq + HotelPinImg + dq;
                //Code Change for Virtual Earth 6.1            
                var pin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(HtlLat, HtlLong), { icon: HotelIcon });
                //var pin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(HtlLat, HtlLong));
                //pin.SetDescription(HtlPopup_Main);  
                //map.AddShape(pin);
                pin.Title = '';
                //pin.setOptions(poptions);
                pin.Description = HtlPopup_Main;

                //Code Change for Virtual Earth 6.1
                // Old Code
                //pin[x].Show();
                // Old Code for Hotel Pin and Details
                /*var pin = new VEPushpin(
                pinID,         //The ID of the pushpin that will be added to the map. The id value must be unique for each pushpin on a map control.
                new VELatLong(HtlLat,HtlLong),   //The location of the pushpin, specified as a VELatLong object.
                HotelPinImg,       //The URL that points to the file you want to use as an icon. Optional.
                '',          //The string to display in the title field of the enhanced preview. Optional.
                HtlPopup_Main       //The string to display in the details field of the enhanced preview. Optional.
                //'iconStyle',       //A cascading style sheet class name that defines the look of the icon. Optional.
                //'titleStyle',       //A cascading style sheet class name that defines the look of the title field of the enhanced preview. Optional.
                //'previewStyle'      //A cascading style sheet class name that defines the look of the description field of the enhanced preview. Optional.
                );
                map.AddPushpin(pin);*/
                var adj_pID = x - ((iHLCurrGroup - 1) * iHLMaxPerGroup); //adjusted pID
                pinArray[adj_pID] = pin;

                Microsoft.Maps.Events.addHandler(pin, 'mouseover', function (e) { displayInfobox(e, loc[x]) });
                Microsoft.Maps.Events.addHandler(pin, 'mouseleave', function (e) { hideInfobox(e, loc[i]) });
                //Microsoft.Maps.Events.addHandler(pin, 'mouseout', function (e) { hideInfobox(e, loc[i]) });
                //Microsoft.Maps.Events.addHandler(pin, 'mouseover', function (e) { GetHotelPopup_Main(adj_pID,HtlName,HtlAddrLine1,HtlAddrLine2,HtlPropertyType,HtlImageURL) });
                dataLayer.push(pin);

            }
            else if (bUpdateInd && (!document.getElementById(ckboxitem).checked))
             {
                  dataLayer.removeAt(x);
            //map.DeleteAllShapes(); //if called from UpdateMap link, delete pins first
              }
        }
    }

    Monday, December 2, 2013 3:27 AM

Answers