Events Made Easy Forums Feature requests Make Map events accessible

Viewing 1 post (of 1 total)
  • Author
  • #61842

    Dear sweet lovely Franky….

    I am wanting to catch an open popup event on the map to do some interesting stuff and find that the events on the map are not going anywhere.

    Can you add an object reference of the map to the map container div so that I can attach event handlers to the div please?

    for example
    in your code do something like…

    			div_arr_map[i] =, myOptions);
    		// GH: Add it to the div as a map object reference..
    		    divs[i].mapObj = div_arr_map[i];
    			// add the title layer
    			L.tileLayer(osmUrl, {attribution: osmAttrib}).addTo(div_arr_map[i]);

    This may also avoid the need to maintain that array of maps in your javascript.

    Then I can do something like…

    jQuery(document).ready(function($) {
    	// Nest a call to ensure we are last on the list.
    	jQuery(document).ready(function($) {
    	var divs = document.getElementsByTagName('div');
    	for (var i = 0; i < divs.length; i++) {
    		var divname = divs[i].id; 
    		if (divname.indexOf("eme_global_map_") === 0) { 
    			divs[i].mapObj.addEventListener("popupopen", mtsSyncPopup);
    	} );
    } );
    function mtsSyncPopup(p) {
    	var tx = p.popup.getContent();
    	var x = tx.split('<br>')[0];
    	document.getElementById("foo").innerHTML = x;

    Keep up the good work..

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.