none
Problem with infobox for many layers RRS feed

  • Question

  • Hi all,
    i'm using the Bing Maps v.7 and trying to develop a small web mapping Aplication.
    i have three layers (three EntityCollections of pushpins, polylines and polygons). i have to show the infoboxes for every geometry objects by event 'mouseover'.
    Problem is, i can't show infoboxes of layers, they at first to map appended. it is showed only the infoboxes of last layer(of upper layer).
    i think, the overlapping and sequence of layers can prevent for mouseover or click events.
    is it possible, that the all geometric objects (pushpins, polylines, polygons) of all three layers by mouseover event to show.

    Can anyone help with a solution? I's about the using of v7.0

     
    Thanks in advance!
    • Moved by Ricky_Brundritt Saturday, March 10, 2012 10:59 AM (From:Bing Maps: Map Control and Web services Development)
    Wednesday, July 20, 2011 1:28 PM

Answers

  • The solution I used was to attach the event to the map, attach to all my elements (pushpins, polygons, etc. ) some index, and then on the event handling I identify the element that was clicked by its type and index. Parts of the code: 

     

     Microsoft.Maps.Events.addHandler(map, "click", MouseClickHandler); 
     pins[k] = new Microsoft.Maps.Pushpin(point);  pins[k].index=k;  //seting the identifier for the pin
    function MouseClickHandler(e) {
         switch (e.targetType){
    	 case "pushpin":
    	       renderPushpinInfobox(e.target.index);
    	       break;
    	  case "polygon":             
                   renderPolygonInfobox(e.target.index);
                   break;
         }
    }

     

    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:41 PM
    Monday, September 12, 2011 2:23 PM
  • Not sure why you need the index. The e.target is the element you want. 
    http://rbrundritt.wordpress.com
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:41 PM
    Tuesday, September 13, 2011 10:07 PM

All replies

  • i believe this is because top most EC does not allows events to pass though. Could you try keeping all entities in one EC?
    MSFT
    Hemant Goyal
    • Edited by Hemant Goyal Wednesday, July 20, 2011 4:35 PM edited type
    Wednesday, July 20, 2011 4:34 PM
  • The solution I used was to attach the event to the map, attach to all my elements (pushpins, polygons, etc. ) some index, and then on the event handling I identify the element that was clicked by its type and index. Parts of the code: 

     

     Microsoft.Maps.Events.addHandler(map, "click", MouseClickHandler); 
     pins[k] = new Microsoft.Maps.Pushpin(point);  pins[k].index=k;  //seting the identifier for the pin
    function MouseClickHandler(e) {
         switch (e.targetType){
    	 case "pushpin":
    	       renderPushpinInfobox(e.target.index);
    	       break;
    	  case "polygon":             
                   renderPolygonInfobox(e.target.index);
                   break;
         }
    }

     

    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:41 PM
    Monday, September 12, 2011 2:23 PM
  • Not sure why you need the index. The e.target is the element you want. 
    http://rbrundritt.wordpress.com
    • Marked as answer by Ricky_Brundritt Wednesday, September 14, 2011 7:41 PM
    Tuesday, September 13, 2011 10:07 PM