var mapdirect= { focus:"mitbankembed" , host:"ca.dep.state.fl.us" , version:"v7.250321_log" , urlVersion:"" , v:"7" , vApi:"" , vApiUsed:"7" , protocol:"https://" , /* STANDARD */ embed:function(a) { var t=this //console.log("embed",a,a.domNode) return new Promise(function(res,rej) { t.loadErrback=function(err) { rej(err) } t.on('load', function() { res(t) }) try{ t.embedMap(a.domNode) }catch(err){rej(err)} }) } , embedMap:function(mapDiv) { var t=this //console.log("embedMap",mapDiv) // embedIt(true) if(document.readyState == "loading") { document.addEventListener("DOMContentLoaded", embedIt, false); } else { embedIt(true)} // DOMContentLoaded already // readyState interactive, complete (or loaded Android?) function embedIt(b) { //console.log("embedIt",b,mapDiv) if(!b)document.removeEventListener("DOMContentLoaded",embedIt) /* embeds the map in the specified DIV element */ // t.callbacks={} // t.promises={} t.mapid=mapDiv t.mapDiv=document.getElementById(mapDiv) if(!t.mapDiv) { var msg="Map DIV with ID='"+mapDiv + "' does not exist!" console.log("ERROR",msg) if(t.loadErrback)t.loadErrback(new Error(msg)) return } t.mapFrame=document.createElement('IFRAME') var url=t.protocol + t.host + "/mapdirect?focus="+t.focus +(t.v?("&v="+t.v):"") +(t.urlVersion!=""?"&version="+t.urlVersion:"") +"&mapid="+t.mapid +"&vApi="+t.vApi +"&vApiUsed="+t.vApiUsed t.mapFrame.src=url t.mapFrame.style.width="100%" t.mapFrame.style.height="100%" t.mapDiv.appendChild(t.mapFrame) function postMessageHandler(event) { var msg=JSON.parse(event.data) , type=msg.type //console.log("postMessageHandler",msg,t.mapid) /* receive postMessage events*/ if( event.origin !== t.protocol +"cadev.dep.state.fl.us" && event.origin !==t.protocol +"castg.dep.state.fl.us" && event.origin !==t.protocol +"ca.dep.state.fl.us" && event.origin !==t.protocol +"ags.dep.state.fl.us" && event.origin !==t.protocol +"agsdev.dep.state.fl.us" || ("mapid" in msg && msg.mapid!==t.mapid) ) return; /* only process messages from trusted origin and for this mapid*/ if(type=="callback") { //console.log("postMessageHandler::type callback",msg,t.mapid) if(msg.iCb) { var iCb=msg.iCb delete msg.iCb delete msg.type t.callbacks[iCb]&&t.callbacks[iCb](msg) delete t.callbacks[iCb] //console.log("t.promises[iCb]",t.promises[iCb]) if(t.promises[iCb])t.promises[iCb](msg) // this is the resolve method of a pending promise created by the client application delete t.promises[iCb] } } else { if(t.ons[type])for(var i=0;i