diff --git a/croutonjs/meetingMap/js/gmapsDelegate.js b/croutonjs/meetingMap/js/gmapsDelegate.js index 93262a2..836112c 100644 --- a/croutonjs/meetingMap/js/gmapsDelegate.js +++ b/croutonjs/meetingMap/js/gmapsDelegate.js @@ -275,7 +275,7 @@ function createMarker ( inCoords, ///< The long/lat for the marker. }); gAllMarkers[gAllMarkers.length] = {ids: inIds, marker: marker}; }; -function addControl(div,pos) { +function addControl(div,pos,cb) { var p = pos; switch(pos) { case 'topright': @@ -288,6 +288,19 @@ function addControl(div,pos) { break; } div.index = 1; + if (cb) { + const observer = new MutationObserver(function (records) { + records.forEach(record => { + record.addedNodes.forEach(n => { + if (n === div) { + observer.disconnect(); + cb(); + } + }); + }) + }); + observer.observe(document, {childList: true, subtree: true}); + } gMainMap.controls[p].push(div); } /************************************************************************************//** diff --git a/croutonjs/meetingMap/js/meeting_map.js b/croutonjs/meetingMap/js/meeting_map.js index fd60086..cd43a2d 100644 --- a/croutonjs/meetingMap/js/meeting_map.js +++ b/croutonjs/meetingMap/js/meeting_map.js @@ -35,9 +35,9 @@ function MeetingMap(inConfig) { * \brief Load the map and set it up. * ****************************************************************************************/ - function loadMap(inDiv, menuContext, handlebarMapOptions=null) { + function loadMap(inDiv, menuContext, handlebarMapOptions=null,cb=null) { if (!gDelegate.isApiLoaded()) { - preloadApiLoadedCallback(loadMap, [inDiv, menuContext, handlebarMapOptions]); + preloadApiLoadedCallback(loadMap, [inDiv, menuContext, handlebarMapOptions, cb]); gDelegate.loadApi(); return; } @@ -54,12 +54,12 @@ function MeetingMap(inConfig) { } }, false); if (config.map_search) { - gDelegate.addControl(createSearchButton(), 'topleft'); + gDelegate.addControl(createSearchButton(), 'topleft', cb); } else if (menuContext) { menuContext.imageDir = config.BMLTPlugin_images; //gDelegate.addControl(createFilterMeetingsToggle(), 'topleft'); - gDelegate.addControl(createMenuButton(menuContext), 'topright'); + gDelegate.addControl(createMenuButton(menuContext), 'topright', cb); }; } }; @@ -124,14 +124,14 @@ function MeetingMap(inConfig) { return controlDiv; } - function loadFromCrouton(inDiv_id, meetings_responseObject, menuContext = null, handlebarMapOptions = null) { + function loadFromCrouton(inDiv_id, meetings_responseObject, menuContext = null, handlebarMapOptions = null, callback) { if (!gDelegate.isApiLoaded()) { - preloadApiLoadedCallback(loadFromCrouton, [inDiv_id, meetings_responseObject, menuContext, handlebarMapOptions]); + preloadApiLoadedCallback(loadFromCrouton, [inDiv_id, meetings_responseObject, menuContext, handlebarMapOptions, callback]); gDelegate.loadApi(); return; } let inDiv = document.getElementById(inDiv_id); - loadMap(inDiv, menuContext, handlebarMapOptions); + loadMap(inDiv, menuContext, handlebarMapOptions,callback); loadAllMeetings(meetings_responseObject, true); }; var fitDuringFilter = true; diff --git a/croutonjs/meetingMap/js/osmDelegate.js b/croutonjs/meetingMap/js/osmDelegate.js index 68db07b..54b9e6c 100644 --- a/croutonjs/meetingMap/js/osmDelegate.js +++ b/croutonjs/meetingMap/js/osmDelegate.js @@ -196,7 +196,7 @@ function openMarker(id) { jQuery(".bmlt-data-row > td").removeClass("rowHighlight"); jQuery("#meeting-data-row-" + id + " > td").addClass("rowHighlight"); } -function addControl(div,pos) { +function addControl(div,pos,cb) { var ControlClass = L.Control.extend({ onAdd: function (map) { return div; @@ -208,6 +208,19 @@ function addControl(div,pos) { var controlConstructor = function(opts) { return new ControlClass(opts); } + if (cb) { + const observer = new MutationObserver(function (records) { + records.forEach(record => { + record.addedNodes.forEach(n => { + if (n === div) { + observer.disconnect(); + cb(); + } + }); + }) + }); + observer.observe(document, {childList: true, subtree: true}); + } controlConstructor({ position: pos }).addTo(gMainMap); } // Low level GeoCoding diff --git a/croutonjs/src/js/crouton-core.js b/croutonjs/src/js/crouton-core.js index 95ac0c2..c0c8d83 100644 --- a/croutonjs/src/js/crouton-core.js +++ b/croutonjs/src/js/crouton-core.js @@ -474,8 +474,7 @@ function Crouton(config) { crouton_Handlebars.registerPartial('meetings', hbs_Crouton.templates['meetings']); crouton_Handlebars.registerPartial('bydays', hbs_Crouton.templates['byday']); crouton_Handlebars.registerPartial('formatPopup', hbs_Crouton.templates['formatPopup']); - croutonMap.initialize(self.createBmltMapElement(),self.meetingData,context); - callback && callback(); + croutonMap.initialize(self.createBmltMapElement(),self.meetingData,context,null,callback); } self.getCurrentLocation = function(callback) { if (navigator.geolocation) { @@ -1120,7 +1119,7 @@ Crouton.prototype.render = function(doMeetingMap = false) { objectPointer: (a) => convertToPunyCode(a.name), optionName: (a)=>a.name}); if (self.config.has_locations) self.dropdownData.push( {placeholder: self.localization.getWord('locations'), pointer: 'Locations', elementId: "filter-dropdown-locations", - uniqueData: (meetings) => getUniqueValuesOfKey(meetings, 'location_text').sort(), + uniqueData: (meetings) => getUniqueValuesOfKey(meetings, 'location_text').map((s)=>s.replace(/(<([^>]+)>)/gi, "")).sort(), objectPointer: convertToPunyCode, optionName: (s)=>s}); if (self.config.has_sub_province) self.dropdownData.push( {placeholder: self.localization.getWord('counties'), pointer: 'Counties', elementId: "filter-dropdown-sub_province",