Infobox element click events don't bubble/propagate up


using maps v8 , infobox populated html content (via description, not htmlcontent). click events triggered on html element not propagating past div.infobox element. , since div.infobox element created/destroyed rather (on setmap , setlocation), difficult keep bound, particularly since there can delay after calling setmap or setlocation before elements created , ready bound. it's mess if use multiple infoboxes.

i'm guessing culprit infobox click event has event.stoppropagation(), perhaps prevent map click event being triggered well? if so, filtering/exclusion should added targets inside infoboxes. mouseenter , mouseleave events on elements still propagate normally, however. have not tested other events.

so summarize:

1) need click event propagate can delegated instead of directly bound

2) need infobox.setmap() trigger kind of domready event events can bound included content without having hack timeout checks

var map = new microsoft.maps.map(document.getelementbyid('mymap'), {      credentials: 'your bing maps key',      center: new microsoft.maps.location(47.60357, -122.32945)  });  var infobox = new microsoft.maps.infobox(map.getcenter(), { title: 'map center', description: 'seattle <div id="div_bubble"><button id="button_click">click me</button></div>' });  infobox.setmap(map);  settimeout(function() {  	var button = document.getelementbyid('button_click');  	button.addeventlistener('click', function(evt) { console.log('button click target:'); console.log(evt.target); }, false);	  	var div = document.getelementbyid('div_bubble');  	div.addeventlistener('click', function(evt) { console.log('div click target:'); console.log(evt.target); }, false);  	document.addeventlistener('click', function(evt) { console.log('document click target:'); console.log(evt.target); }, false);  }, 5000);    


i have given lot of thought around this. going extent have requested leads me suggest taking @ customoverlays. custom overlays fire once available in dom. here documentation these:

https://msdn.microsoft.com/en-us/library/mt762871.aspx

https://msdn.microsoft.com/en-us/library/mt762874.aspx

custom overlays pretty powerful. so i've started using them prototype new features dev team has been able add in base map control without needing changes integrate them in.

that said, keep things simple have requested original event object fired returned in infoboxes event object. doing can use standard map event functionality , @ object original event occurred on , check it's id or class property (which ever want use uniquely identify buttons). think keep things simple.  


[blog] [twitter] [linkedin]



Bing Maps  >  Bing Maps Web Controls



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'