var mapdirect=
{
focus:"solarispiembed"
, host:"ca.dep.state.fl.us"
, version:"v7.250502x_log_stcm_13b"
, 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)
// simulate callback post message from api
// 250324
t.postMessage({type:"cb_load"})
t.isReady=true
res({type:"load"})
})
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,msg.type)
if(msg.iCb)
{
var iCb=msg.iCb, cmd=msg.cb_cmd
delete msg.iCb
delete msg.type
if(t.callbacks[iCb]){
t.callbacks[iCb](msg)
t.postMessage({type:"client_callback_resolved",event:cmd})
}else{
t.postMessage({type:"client_has_no_callback",event:cmd})
}
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
t.postMessage({type:"client_promise_resolved",event:cmd})
}else{
t.postMessage({type:"client_has_no_promise",event:cmd})
}
delete t.promises[iCb]
}
} else
{
if(t.ons[type])for(var i=0;ithis.postMessage(obj),10)
} else t.mapFrame.contentWindow.postMessage(JSON.stringify(obj),'*')
}
, ons:{}
, callbacks:{}
, promises:{}
}
;(async function(){
let {default:custom}=await import("https://ca.dep.state.fl.us/mapdirect/v7.250502x_log_stcm_13b/api/solarispiembed.js")
for(var prop in custom)mapdirect[prop]=custom[prop]
console.log("loaded api:",mapdirect)
})()