var mapdirect= { focus:"btldsrefreshembed" , host:"ca.dep.state.fl.us" , version:"v7.250131" , urlVersion:"" , v:"7" , vApi:"" , vApiUsed:"7" , protocol:"https://" , /* CUSTOM */ /* EVENTS: *{type:"load"}: map and its layers are fully loaded. client app can enable UI and begin sending commands to map. *{"type":"selection","selection":{"Counties":["Bay"],"State Owned Facilities":["F3884","F3885","F3883","F4050"]}} : a selection has completed. the value of resultField for each layer with a result is returned. this is returned when no results found: {"type":"selection","selection":{}} */ searchByDocumentKey:function(values) // comma separated values { this.postMessage({type:"searchByDocumentKey",value:values}) } , searchByBtldsParcelKey:function(values) // comma separated values { this.postMessage({type:"searchByBtldsParcelKey",value:values}) } , print:function(a) /* creates pdf showing only specified ids and zoomed in on them width , height , dpi , ids // document key as array of numeric values */ { a.type="print" this.postMessage(a) } , /* 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