/* TerraFly API -=START=- */ if(typeof deconcept == "undefined") var deconcept = new Object(); if(typeof deconcept.util == "undefined") deconcept.util = new Object(); if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object(); deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) { if (!document.getElementById) { return; } this.DETECT_KEY = detectKey ? detectKey : 'detectflash'; this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if(swf) { this.setAttribute('swf', swf); } if(id) { this.setAttribute('id', id); } if(w) { this.setAttribute('width', w); } if(h) { this.setAttribute('height', h); } if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); } this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(); if (!window.opera && document.all && this.installedVer.major > 7) { // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE deconcept.SWFObject.doPrepUnload = true; } if(c) { this.addParam('bgcolor', c); } var q = quality ? quality : 'high'; this.addParam('quality', q); this.setAttribute('useExpressInstall', false); this.setAttribute('doExpressInstall', false); var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location; this.setAttribute('xiRedirectUrl', xir); this.setAttribute('redirectUrl', ''); if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); } } deconcept.SWFObject.prototype = { useExpressInstall: function(path) { this.xiSWFPath = !path ? "expressinstall.swf" : path; this.setAttribute('useExpressInstall', true); }, setAttribute: function(name, value){ this.attributes[name] = value; }, getAttribute: function(name){ return this.attributes[name]; }, addParam: function(name, value){ this.params[name] = value; }, getParams: function(){ return this.params; }, addVariable: function(name, value){ this.variables[name] = value; }, getVariable: function(name){ return this.variables[name]; }, getVariables: function(){ return this.variables; }, getVariablePairs: function(){ var variablePairs = new Array(); var key; var variables = this.getVariables(); for(key in variables){ variablePairs[variablePairs.length] = key +"="+ variables[key]; } return variablePairs; }, getSWFHTML: function() { var swfNode = ""; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute('swf', this.xiSWFPath); } swfNode = ' 0){ swfNode += 'flashvars="'+ pairs +'"'; } swfNode += '/>'; } else { // PC IE if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute('swf', this.xiSWFPath); } //'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0', //mingjin swfNode = ''; //swfNode = ''; if ( g_isAutoInstallFlashPlayer == true ) { swfNode = ''; } else { swfNode = ''; } swfNode += ''; var params = this.getParams(); for(var key in params) { swfNode += ''; } var pairs = this.getVariablePairs().join("&"); if(pairs.length > 0) {swfNode += '';} swfNode += ""; } return swfNode; }, write: function(elementId){ if(this.getAttribute('useExpressInstall')) { // check to see if we need to do an express install var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]); if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) { this.setAttribute('doExpressInstall', true); this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl'))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } //mingjin if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){ if( g_isAutoInstallFlashPlayer||this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = "";//this.getSWFHTML(); //mj // - START - // - Xingxing: Add a DIV for message bar. n.innerHTML = this.getSWFHTML() + "
"; //n.innerHTML = "
" + this.getSWFHTML(); // - Notice: NEVER use the following style. It'll cause an ERROR in IE. // - n.innerHTML = this.getSWFHTML(); // - n.innerHTML += " ... " // - END - //document.write( this.getSWFHTML()); return true; }else{ if(this.getAttribute('redirectUrl') != "") { document.location.replace(this.getAttribute('redirectUrl')); } } return false; } } /* ---- detection functions ---- */ deconcept.SWFObjectUtil.getPlayerVersion = function(){ var PlayerVersion = new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins && navigator.mimeTypes.length){ var x = navigator.plugins["Shockwave Flash"]; if(x && x.description) { PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE var axo = 1; var counter = 3; while(axo) { try { counter++; axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter); // document.write("player v: "+ counter); PlayerVersion = new deconcept.PlayerVersion([counter,0,0]); } catch (e) { axo = null; } } } else { // Win IE (non mobile) // do minor version lookup in IE, but avoid fp6 crashing issues // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ try{ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); }catch(e){ try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); PlayerVersion = new deconcept.PlayerVersion([6,0,21]); axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code) } catch(e) { if (PlayerVersion.major == 6) { return PlayerVersion; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if (axo != null) { PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } return PlayerVersion; } deconcept.PlayerVersion = function(arrVersion){ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0; this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0; this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0; } deconcept.PlayerVersion.prototype.versionIsValid = function(fv){ if(this.major < fv.major) return false; if(this.major > fv.major) return true; if(this.minor < fv.minor) return false; if(this.minor > fv.minor) return true; if(this.rev < fv.rev) return false; return true; } /* ---- get value of query string param ---- */ deconcept.util = { getRequestParameter: function(param) { var q = document.location.search || document.location.hash; if (param == null) { return q; } if(q) { var pairs = q.substring(1).split("&"); for (var i=0; i < pairs.length; i++) { if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { return pairs[i].substring((pairs[i].indexOf("=")+1)); } } } return ""; } } /* fix for video streaming bug */ deconcept.SWFObjectUtil.cleanupSWFs = function() { var objects = document.getElementsByTagName("OBJECT"); for (var i = objects.length - 1; i >= 0; i--) { objects[i].style.display = 'none'; for (var x in objects[i]) { if (typeof objects[i][x] == 'function') { objects[i][x] = function(){}; } } } } // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/ if (deconcept.SWFObject.doPrepUnload) { if (!deconcept.unloadSet) { deconcept.SWFObjectUtil.prepUnload = function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){}; window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs); } window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload); deconcept.unloadSet = true; } } /* add document.getElementById if needed (mobile IE < 5) */ if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }} /* add some aliases for ease of use/backwards compatibility */ var getQueryParamValue = deconcept.util.getRequestParameter; var FlashObject = deconcept.SWFObject; // for legacy support var SWFObject = deconcept.SWFObject; ////////////////////////////////////////////////////////////////////////////////// /* Terrafly API Object Oriented Wrap for Flash object */ ////////////////////////// // the path where the Terrafly API Flash locate /* Path */ // engine with fmap var g_server_flash_name_fmap = "TerraFly_API_201210051537.swf"; //var g_server_flash_name_fmap = "TerraFly_API_201208031055.swf"; // engine with mapnik //var g_server_flash_name = "TerraFly_API_201301081836.swf"; //var g_server_flash_name = "TerraFly_API_201304101105.swf"; //var g_server_flash_name = "TerraFly_API_201311010204.swf"; //var g_server_flash_name = "TerraFly_API_201311061747.swf"; //var g_server_flash_name = "TerraFly_API_201403101212.swf"; var g_server_flash_name = "TerraFly_API_20140421.swf"; var g_flash_minimal_version = "10"; //var g_flash_background_color = "#FFFFFF"; var g_flash_background_color = "#99B3CC"; // for ADCI map mode //var g_flash_background_color = "EFEBE2"; var g_flash_max_size = 3000; // used for automatically generator map ID var g_flash_object_base_ID = "TerraFlyFlashObj_ID"; var g_mapID_Num = 1; var g_codeBaseURL = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0"; //var g_codeBaseURL = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"; var g_isAutoInstallFlashPlayer = true; function TMap( container, latitude, longitude, level, onLoadCallBackFunction, bufferSize, isAutoInstallFlashPlayer, mapEngine, initMapType/*optional*/, mapSource, zoomPanelMode) { if (mapSource == null) { mapSource = "best_available"; } if (zoomPanelMode == null) { zoomPanelMode = "normal"; } // generate swf file path if (mapEngine == "h") { // h for old fmap server_flash_name = g_server_flash_name_fmap; } else { server_flash_name = g_server_flash_name; } var g_server_ip = '131.94.133.154'; var g_server_flash_path = 'http://' + g_server_ip + '/api/swf/' + server_flash_name; //alert(g_server_ip); var width, height; // the global object of the flash object instance. this.m_flashObject = null; g_isAutoInstallFlashPlayer = true; if (isAutoInstallFlashPlayer != null && isAutoInstallFlashPlayer == false ) { g_isAutoInstallFlashPlayer = false; } //////////////////////////////////////////////////////////////////////////////// // the Constructor part ///////////////////////////////////////////////////////////////////////////////// // // check if the container is correct if ( container == null || container.tagName.toUpperCase() != "DIV" ) { TErrorMsg("Error: The map container should be a DIV element in HTML! "); return; } //TODO: the other unit should be supported in the future, here only pixels supported! ??/ if ( container.offsetWidth == null || container.offsetWidth.length == 0 ) { TErrorMsg("Error: The [width] of the map container DIV element should be explicitly stated ! "); return; } if ( container.offsetHeight == null || container.offsetHeight.length == 0 ) { TErrorMsg("Error: The [height] of the map container DIV element should be explicitly stated ! "); return; } width = container.style.width; height = container.style.height; //TODO : check if the latitude, longitude is in the correct range. // if ( latitude != 0 && longitude !=0 && resolution !=0 ) // { // // ???? // } if ( (level == null) || (!( level >= 1 && level < 22 )) ) { level = 5; } level = number_clip (level,1,22); level = Math.floor( level ); if( (bufferSize == null)||(isNaN(bufferSize)) ) { bufferSize = 0; } else { bufferSize = Math.floor(bufferSize); } // check if the length and height is correct. var widthFlash = parseInt( width ); var heightFlash = parseInt( height ); if ( widthFlash <= 0 || widthFlash >= g_flash_max_size || heightFlash <= 0 || heightFlash >= g_flash_max_size ) { //alert("Error: The TerraMap size is incorrect "); } widthFlash = number_clip(widthFlash,0,g_flash_max_size); heightFlash = number_clip(heightFlash,0,g_flash_max_size); // generate Unique ID for flash object. this.m_flashObjectID = g_flash_object_base_ID + g_mapID_Num ; g_mapID_Num++; // Creates a new map inside of the given HTML container, which is typically a DIV element var m_SWFOject = new SWFObject( g_server_flash_path, this.m_flashObjectID, widthFlash, heightFlash, g_flash_minimal_version, g_flash_background_color ); // be careful with the width, height, do we have a way to dynamically change the width and height??? // we need to find a way in the future in case we need to adjust the size of the map, // such as to in Terrafly 2.5D m_SWFOject.addParam("quality","high"); m_SWFOject.addParam("salign", "lt"); m_SWFOject.addParam("scale", "NoScale"); m_SWFOject.addParam("allowScriptAccess", "always"); m_SWFOject.addParam("allowFullScreen", "true"); m_SWFOject.addParam("wmode", "opaque"); // 1. set map initialize parameters // 1.1 get client IP address var client_jcq = 30; var client_ip = '131.94.129.228'; var client_ip_array = client_ip.split('.'); // 1.2 get Jpeg quaility if( (parseInt(client_ip_array[0])==131)&& (parseInt(client_ip_array[1])==94) ) { client_jcq = 80; } else { client_jcq = 80; } //alert("client ip = " + client_ip + "\njcq = " + client_jcq); //alert(initMapType); if(initMapType == undefined) { initMapType = "hybrid"; } // 1.3 insert Flash parameters m_SWFOject.addVariable("initLat", latitude); m_SWFOject.addVariable("initLng", longitude); m_SWFOject.addVariable("initLevel", level); m_SWFOject.addVariable("initBuffer", bufferSize); m_SWFOject.addVariable("initJcq", client_jcq); m_SWFOject.addVariable("m_WebViewWidth",widthFlash); m_SWFOject.addVariable("m_WebViewHeight",heightFlash); m_SWFOject.addVariable("m_serverIP",g_server_ip); m_SWFOject.addVariable("m_mapType",initMapType.toUpperCase()); m_SWFOject.addVariable("initSatelliteSource", mapSource); m_SWFOject.addVariable("zoomPanelMode", zoomPanelMode); var strGlobalFunctor = FunctorGlobalize( onLoadCallBackFunction ); var CallbackFunctionWithDelay = "function() { setTimeout( " + strGlobalFunctor + ", 20);}"; var OnloadFunctorString = encodeURIComponent(CallbackFunctionWithDelay.toString()); m_SWFOject.addVariable("m_FlashOnLoadJSEventFunction", OnloadFunctorString); //m_SWFOject.useExpressInstall('http://tv2.cs.fiu.edu/TerraFly_API/scripts/expressinstall.swf'); var expressInstallPath = 'http://' + g_server_ip + '/tm/expressInstall.swf'; m_SWFOject.useExpressInstall(expressInstallPath); container.innerHTML = "
"; var swfContainer = document.getElementById( 'g_swfContainer'+g_mapID_Num ); if(TBrowserIsCompatible()) { m_SWFOject.write( swfContainer ); } else { swfContainer.innerHTML = "Your device is not compatible with Flash."; } this.m_flashObject = document.getElementById( this.m_flashObjectID ); if ( this.m_flashObject == null ) { TErrorMsg("Error: TerraFly is unable to display because Flash Plugin is not installed. Download ..."); } // end of constuctor of the map object ///////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////// // the APIs Message Bar ////////////////////////////////////////////////////////////////////////////////// // - Xingxing: Add a DIV for message bar. document.getElementById( "g_TerraFlyMessageBarContainer" ).style.backgroundColor = "#73a1e5" document.getElementById( "g_TerraFlyMessageBarContainer" ).style.width = "100%"; var g_TerraFlyMessageBar_Alpha = 100; var g_TerraFlyMessageBar_FadeEndAlpha = 0; var g_TerraFlyMessageBar_FadeSign = 0; var g_TerraFlyMessageBar_Interval; this.SetMessageText = function ( msgHTML ) { document.getElementById( "g_TerraFlyMessageBarContainer" ).style.display = "block"; document.getElementById( "g_TerraFlyMessageBar" ).innerHTML = msgHTML; } this.ShowMessageBar = function () { if(g_TerraFlyMessageBar_Interval != null) { clearInterval(g_TerraFlyMessageBar_Interval); g_TerraFlyMessageBar_Interval = null; } this.SetMessageAlpha(100); } this.HideMessageBar = function () { if(g_TerraFlyMessageBar_Interval != null) { clearInterval(g_TerraFlyMessageBar_Interval); g_TerraFlyMessageBar_Interval = null; } document.getElementById( "g_TerraFlyMessageBar" ).innerHTML = ""; document.getElementById( "g_TerraFlyMessageBarContainer" ).style.display = "none"; } this.SetMessageAlpha = function ( alpha ) { document.getElementById( "g_TerraFlyMessageBarContainer" ).style.opacity = alpha/100; document.getElementById( "g_TerraFlyMessageBarContainer" ).style.filter = "alpha(opacity="+alpha+")"; } this.MBFadeAni = function (startAlpha, endAlpha) { g_TerraFlyMessageBar_Alpha = parseInt(startAlpha); g_TerraFlyMessageBar_FadeEndAlpha = parseInt(endAlpha); if(startAlpha < endAlpha) { g_TerraFlyMessageBar_FadeSign = 1; } else { g_TerraFlyMessageBar_FadeSign = -1; } g_TerraFlyMessageBar_Interval = setInterval( this.MBFadeCheck, 50); } this.MBFadeCheck = function () { if( ( (g_TerraFlyMessageBar_Alpha > g_TerraFlyMessageBar_FadeEndAlpha)&&(g_TerraFlyMessageBar_FadeSign < 0) ) || ( (g_TerraFlyMessageBar_Alpha < g_TerraFlyMessageBar_FadeEndAlpha)&&(g_TerraFlyMessageBar_FadeSign > 0) ) ) { document.getElementById( "g_TerraFlyMessageBarContainer" ).style.opacity = g_TerraFlyMessageBar_Alpha/100; document.getElementById( "g_TerraFlyMessageBarContainer" ).style.filter = "alpha(opacity="+g_TerraFlyMessageBar_Alpha+")"; g_TerraFlyMessageBar_Alpha += (10*g_TerraFlyMessageBar_FadeSign); } else { document.getElementById( "g_TerraFlyMessageBarContainer" ).style.opacity = g_TerraFlyMessageBar_FadeEndAlpha/100; document.getElementById( "g_TerraFlyMessageBarContainer" ).style.filter = "alpha(opacity="+g_TerraFlyMessageBar_FadeEndAlpha+")"; clearInterval(g_TerraFlyMessageBar_Interval); g_TerraFlyMessageBar_Interval = null; } } ////////////////////////////////////////////////////////////////////////////////// // the APIs interface ////////////////////////////////////////////////////////////////////////////////// /* removed on 2/24/2009, not necessary this.SetImageURL = function ( newURL ) { this.m_flashObject.SetImageURL( newURL ); } this.SetOverlayURL = function ( newURL ) { this.m_flashObject.SetOverlayURL( newURL ); } */ this._CenterLock = false; this.PanTo = function( latitude, longitude ) { /* Keep the following line for reference */ //this.m_flashObject.MoveToGDCoord(latitude, longitude ); if(!this._CenterLock) { //this.LockCenter(); this.m_flashObject.MoveToGDCoord(latitude, longitude ); } else { //Retry setTimeout(this.PanTo, 10, latitude, longitude ); } } this.CenterTo = function( latitude, longitude, level) { /* Keep the following line for reference */ //this.m_flashObject.SetMapCenter(latitude, longitude, level ); if(!this._CenterLock) { //this.LockCenter(); this.m_flashObject.SetMapCenter(latitude, longitude, level ); } else { //Retry setTimeout(this.CenterTo, 10, latitude, longitude, level ); } } this.GetCenter = function() { var centerArray = ( this.m_flashObject.GetMapCenter() ).split(";") ; var centerObj = new Object; centerObj.Latitude = centerArray[0]; centerObj.Longitude = centerArray[1]; //alert( centerObj.Latitude + "\n" + centerObj.Longitude); return centerObj; } this.PanToAni = function( latitude, longitude, speed, callbackFunction ) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); this.m_flashObject.PanToAni( latitude, longitude, speed, strGlobalFunctor ); } this.SetZoomPanelMode = function(mode) { this.m_flashObject.setZoomPanelMode(mode); } this.ZoomTo = function(level) { /* Keep the following line for reference */ //this.SetLevel(level); if(!this._CenterLock) { //this.LockCenter(); this.SetLevel( level ); } else { //Retry //alert("delay zoom"); setTimeout(this.ZoomTo, 10, level ); } } this.ZoomToAni = function( level, callbackFunction ) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); this.m_flashObject.ZoomToAni( level, strGlobalFunctor ); } this.LockCenter = function() { //alert("lock"); this._CenterLock = true; setTimeout(this.UnlockCenter ,5); } this.UnlockCenter = function() { //alert("unlock"); this._CenterLock = false; } this.GetBounds = function() { //"{ X1: , Y1: , X2: , Y2: }" is the format of returen result of the function GetBoundaryString() var strBoundary = this.m_flashObject.GetBoundaryString(); eval("var objBoundary = " + strBoundary + ";"); return objBoundary; } this.ScreenToGlobal = function(xPixel, yPixel) { var strGlobal = this.m_flashObject.ScreenToGlobal(xPixel, yPixel); eval("var objGlobal = " + strGlobal + ";"); return objGlobal; } this.GlobalToScreen = function(Lat, Lng) { var strScreen = this.m_flashObject.GlobalToScreen(Lat, Lng); eval("var objScreen = " + strScreen + ";"); return objScreen; } this.GetResolution = function() { return TGetResolutionByLevel( this.m_flashObject.GetLevel() ); } this.SetSize = function(width, height) { this.m_flashObject.width = width; this.m_flashObject.height = height; this.m_flashObject.SetViewSize(width,height); //this.m_flashObject.StageResize(); } this.MoveOffsetPixel = function(x,y) { this.m_flashObject.MoveOffsetPixel(x,y); } this.SetLevel = function(level) { level = Math.floor( level ); if( (level >= 1) && (level < 22) ) { this.m_flashObject.ZoomTo(level); } else { //alert("This resolution is not supported."); } } this.GetLevel = function() { return this.m_flashObject.GetLevel(); } this.AddLayer = function(strLayerName, strLayerDesc, isChecked, isSecret, layerColor) { //alert(strLayerName +" "+ strLayerDesc+" "+ isSecret); var newLayerID = this.m_flashObject.AddLayer(strLayerName, strLayerDesc, isChecked, isSecret, layerColor); var newLayerObj = new TLayer( this.m_flashObject, newLayerID ); return newLayerObj; } this.RemoveLayer = function ( layerObj ) { this.m_flashObject.RemoveLayer( layerObj.m_layerFlash_ID ); } this.ShowInfoWindow = function(latitude, longtitude, styleStr, myLabel, myContent) { formatedStyleStr = styleStr.replace(/ /,""); this.m_flashObject.ShowInfoWindowByGDCoord( latitude, longtitude, formatedStyleStr, myLabel, myContent, false ); } this.ShowInfoWindowTabs = function(latitude, longtitude, styleStr, myLabel, myContent) { contentStr = GetContentString(myContent); formatedStyleStr = styleStr.replace(/ /,""); this.m_flashObject.ShowInfoWindowByGDCoord( latitude, longtitude, formatedStyleStr, myLabel, contentStr, true ); } this.HideInfoWindow = function() { this.m_flashObject.SetPanelVisibility("INFO", "HIDDEN"); } this.AddOnClickListener = function(callbackFunction) // callback could be functor directly { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnClickListener( strGlobalFunctor ); // this will pass all the code in callback function as string format. return eventID; } this.AddOnDoubleClickListener = function(callbackFunction) // callback could be functor directly { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnDoubleClickListener( strGlobalFunctor ); // this will pass all the code in callback function as string format. return eventID; } this.AddOnMoveEndListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnMoveEndListener( strGlobalFunctor ); return eventID; } this.AddOnZoomEndListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnZoomEndListener( strGlobalFunctor ); return eventID; } this.AddOnLegendChangeListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnLegendChangeListener( strGlobalFunctor ); return eventID; } this.AddOnModeChangeListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnModeChangeListener( strGlobalFunctor ); return eventID; } this.AddOnFlyEndListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnFlyEndListener( strGlobalFunctor ); return eventID; } this.AddOnFlyCrashedListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnFlyCrashedListener( strGlobalFunctor ); alert("AddOnFlyCrashedListener: " + eventID); return eventId; } this.AddOnFullScreenListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnFullScreenListener( strGlobalFunctor ); return eventID; } this.AddOnTileAddedListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnTileAddedListener( strGlobalFunctor ); return eventID; } this.AddOnTileRemovedListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddMapOnTileRemovedListener( strGlobalFunctor ); return eventID; } this.AddDebugListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); var eventID = this.m_flashObject.AddFlashDebugOutputListener( strGlobalFunctor ); return eventID; } this.RemoveListener = function(listenerID) { this.m_flashObject.RemoveMapListener( listenerID ); } this.SetBorderVisibility = function ( visible ) { if (visible == true || visible == false) { this.m_flashObject.SetBorderVisibility(visible); } } this.SetPanelVisibility = function ( strPanel, strVis ) { //alert(this.m_flashObject.id); this.m_flashObject.SetPanelVisibility(strPanel, strVis); } this.SetPanelPosition = function( strPanel, _x,_y) { this.m_flashObject.SetPanelPosition( strPanel, _x, _y); } this.SetFullScreenButtonVisibility = function( visible ) { if (visible == true) { this.m_flashObject.SetPanelVisibility("FULL", "MAX"); } else if (visible == false) { this.m_flashObject.SetPanelVisibility("FULL", "HIDDEN"); } else { TErrorMsg("Only boolean parameters are accepted by Function SetFullScreenButtonVisibility !"); } } this.SetLogoVisibility = function( visible ) { if (visible == true || visible == false) { this.m_flashObject.SetLogoVisibility( visible ); } else { TErrorMsg("Only boolean parameters are accepted by Function SetLogoVisibility !"); } } this.SetLegend = function ( legendStr ) { this.m_flashObject.AddLegend( legendStr ); } this.FullScreen = function() { this.m_flashObject.FullScreen("FULL"); } this.AddCustomizedButton = function(buttonX, buttonY, buttonIconURL) { var newButtonID = this.m_flashObject.AddUserButton(buttonX, buttonY, buttonIconURL); var newButtonObj = new TButton( this.m_flashObject, newButtonID ); return newButtonObj; } this.GetFlyMode = function () { var flymode = this.m_flashObject.isFlying(); return flymode; } this.SetFlyMode = function ( bool ) { //No Longer Supported //var flymode = this.m_flashObject.SetFlyMode(bool); //return flymode; return false; } this.SetTFPassTroughString = function( PassTroughString ) { this.m_flashObject.SetTFPassTroughString( PassTroughString ); } this.PauseFly = function() { return this.m_flashObject.PauseFly(); } this.ContinueFly = function() { return this.m_flashObject.ContinueFly(); } this.StopFly = function() { return this.m_flashObject.StopFlyAni(); } this.MapMode = function( mode ) { //this.m_flashObject.ChangeType(mode); } this.SetMapOnAreaSelectedListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); this.m_flashObject.SetMapOnAreaSelectedListener( strGlobalFunctor ); } this.ShowAreaSelector = function () { this.m_flashObject.ShowSelectRectangle(); } this.HideAreaSelector = function () { this.m_flashObject.HideSelectRectangle(); } /* this.SelectRectangle = function ( callbackFunction ) { var strGlobalFunctor = FunctorGlobalize(callbackFunction); this.m_flashObject.SelectRectangle( strGlobalFunctor ); } */ /* this.RectangleReturn = function() { //"{ X1: , Y1: , X2: , Y2: }" is the format of returen result of the function GetBoundaryString() var strBoundary = this.m_flashObject.GetBoundaryString(); eval("var objBoundary = " + strBoundary + ";"); return objBoundary; } */ this.ViewDebugPanel = function( bool ) { this.m_flashObject.Debug_Log( bool ); } this.ViewTileURL = function( bool ) { this.m_flashObject.Debug_URL( bool ); } this.GetOverlayComposite = function() { return this.m_flashObject.getOverlayComposite(); } this.GetColorByLatLng = function(latitude, longitude) { return this.m_flashObject.getColorByLatLng(latitude, longitude); } this.SetSource = function(source) { return this.m_flashObject.setSource(source); } this.GetSource = function() { return this.m_flashObject.getSource(); } this.GetFPS = function() { return this.m_flashObject.getFPS(); } this.SetFPS = function(fps) { return this.m_flashObject.setFPS(fps); } /* this.EITest = function() { //alert(this.m_flashObject.name); this.m_flashObject.EITest(); } */ } /////////////////////////////////////////////////////////////////////// TGetBoundsZoomLevel = function(pointNW, pointSE, _width, _height) { var res1 = DistanceLngLat(pointNW.longitude, pointNW.latitude, pointNW.longitude, pointSE.latitude)/_height; var res2 = DistanceLngLat(pointNW.longitude, pointNW.latitude, pointSE.longitude, pointNW.latitude)/_width; var res = ( res1 > res2 ) ? res1 : res2; return TGetLevelByResolution(res)-1; } /////////////////////////////////////////////////////////////////////// function DistanceLngLat(lng1, lat1, lng2, lat2) { var REarth = 6.371229*1e6; var PI = 3.14; var lng1Radian = lng1*PI/180; var lng2Radian = lng2*PI/180; var lat1Radian = lat1*PI/180; var lat2Radian = lat2*PI/180; var distance = REarth * Math.acos( Math.cos(lat1Radian) * Math.cos(lat2Radian) * Math.cos(lng1Radian-lng2Radian) + Math.sin(lat1Radian)*Math.sin(lat2Radian) ); return distance; } /////////////////////////////////////////////////////////////////////// // the definition of the a point composed of its geographical location function TLatLng(latitude, longitude) { this.latitude = latitude; this.longitude = longitude; } ////////////////////////////////////////// // the definition of the layer function TLayer( flashObject ,layer_flash_ID ) { if (flashObject == null || layer_flash_ID == null || layer_flash_ID.toString().length == 0 ) { TErrorMsg("Errro: the flashObject or Layer_flash_id should not be null"); } this.m_flashObject = flashObject; this.m_layerFlash_ID = layer_flash_ID; this.AddMarker = function (latitude, longtitude, label) { var markID = this.m_flashObject.AddMarkGDCoord( this.m_layerFlash_ID, latitude, longtitude, label); var objNewMarker = new TMarker( this.m_flashObject, this.m_layerFlash_ID, markID ); return objNewMarker; } this.AddImgMarker = function (latitude, longtitude, _url, styleStr) { var markID = this.m_flashObject.AddImgMarkerGDCoord( this.m_layerFlash_ID, latitude, longtitude, _url, styleStr); var objNewMarker = new TMarker( this.m_flashObject, this.m_layerFlash_ID, markID ); return objNewMarker; } this.AddPolygon = function (strPoints, strStyle) { var polygonID = this.m_flashObject.AddPolygon(this.m_layerFlash_ID, strPoints, strStyle); var objNewPolygon = new TPolygon( this.m_flashObject, this.m_layerFlash_ID, polygonID ); return objNewPolygon; } this.AddGroundTile = function (_url, latitudeLT, longtitudeLT, latitudeRB, longtitudeRB) { var gtID = this.m_flashObject.AddGroundTile( this.m_layerFlash_ID, _url, latitudeLT, longtitudeLT, latitudeRB, longtitudeRB); //alert("AddGroundTile loaded: " + gtID); var objNewMarker = new TMarker( this.m_flashObject, this.m_layerFlash_ID, gtID ); return objNewMarker; } this.RemovePolygon = function ( polygonObj ) { this.m_flashObject.RemovePolygon( polygonObj.m_layer_flash_ID, polygonObj.m_polygon_flash_ID ); } this.SetVisible = function(bool) { this.m_flashObject.SetLayerVisibility( this.m_layerFlash_ID, bool ); } /* commented on 04/21/2009: useless this.GetMarkers=function() { var markerArray = this.m_flashObject.GetMarkers( this.m_layerFlash_ID ); return markerArray; } */ this.RemoveMarker = function ( markerObj ) { this.m_flashObject.RemoveMarker( markerObj.m_layer_flash_ID, markerObj.m_marker_flash_ID ); } this.RemoveGroundTile = function ( markerObj ) { this.m_flashObject.RemoveGroundTile( this.m_layerFlash_ID, markerObj.m_marker_flash_ID ); } this.SetAllMarkersStyle = function ( strStyle ) { this.m_flashObject.SetAllMarkersStyle(this.m_layerFlash_ID, strStyle); } this.Clean = function () { //alert("Clean " + this.m_layerFlash_ID); this.m_flashObject.CleanLayer(this.m_layerFlash_ID); } } ////////////////////////////////////////// // the definition of user defined buttons; function TButton( flashObject, button_flash_ID ) { if (flashObject == null || button_flash_ID == null || button_flash_ID.toString().length == 0) { TErrorMsg("Errro: the flashObject, button_flash_ID should not be null"); } this.m_flashObject = flashObject; this.m_button_flash_ID = button_flash_ID; this.SetOnClickListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize( callbackFunction ); this.m_flashObject.SetUserButtonOnClickListener( this.m_button_flash_ID, strGlobalFunctor ); } } ////////////////////////////////////////// // TLegend's useless beecause AddLegendGroup was replaced. /* function TLegend( flashObject ,legend_flash_ID ) { if (flashObject == null || legend_flash_ID == null || legend_flash_ID.toString().length == 0 ) { TErrorMsg("Errro: the flashObject or Legend_flash_id should not be null"); } this.m_flashObject = flashObject; this.legend_flash_ID = legend_flash_ID; this.AddLegendItem = function ( label , iconURL, descript) { this.m_flashObject.AddLegendItem( this.legend_flash_ID, label , iconURL, descript); } } */ ////////////////////////////////////////// // the definition of the marker; function TMarker( flashObject, layer_flash_ID, marker_flash_ID ) { if (flashObject == null || layer_flash_ID == null || layer_flash_ID.toString().length == 0 || marker_flash_ID == null || marker_flash_ID.toString().length == 0 ) { TErrorMsg("Errro: the flashObject, Layer_flash_id or marker_flash_ID should not be null"); } this.m_flashObject = flashObject; this.m_layer_flash_ID = layer_flash_ID; this.m_marker_flash_ID = marker_flash_ID; this.SetVisible = function( bool ) { this.m_flashObject.SetMarkerVisibility(this.m_layer_flash_ID, this.m_marker_flash_ID, bool ); } this.ShowInfoWindow = function(styleStr, myLabel, myContent) { formatedStyleStr = styleStr.replace(/ /,""); this.m_flashObject.ShowInfoWindowByID( this.m_layer_flash_ID, this.m_marker_flash_ID, formatedStyleStr, myLabel, myContent, false ); } this.ShowInfoWindowTabs = function(styleStr, myLabel, myContent) { contentStr = GetContentString(myContent); formatedStyleStr = styleStr.replace(/ /,""); this.m_flashObject.ShowInfoWindowByID(this.m_layer_flash_ID, this.m_marker_flash_ID, formatedStyleStr, myLabel, contentStr, true ); } this.SetOnClickListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize( callbackFunction ); this.m_flashObject.SetMarkOnClickListener(this.m_layer_flash_ID, this.m_marker_flash_ID, strGlobalFunctor ); } this.SetOnRolloverListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize( callbackFunction ); this.m_flashObject.SetMarkOnRolloverListener(this.m_layer_flash_ID, this.m_marker_flash_ID, strGlobalFunctor ); } this.MoveTo = function(latitude, longitude) { this.m_flashObject.MoveMarkerTo(this.m_layer_flash_ID, this.m_marker_flash_ID, latitude, longitude); } this.MoveToAni = function(latitude, longitude, speed, moveEndCallback) { var strGlobalFunctor = FunctorGlobalize( moveEndCallback ); this.m_flashObject.MoveMarkerToAni(this.m_layer_flash_ID, this.m_marker_flash_ID, latitude, longitude, speed, strGlobalFunctor); } this.GetPosition = function() { return this.m_flashObject.GetMarkerPosition(this.m_layer_flash_ID, this.m_marker_flash_ID); } this.SetMarkerStyle = function(strStyle) { this.m_flashObject.SetMarkerStyle(this.m_layer_flash_ID, this.m_marker_flash_ID, strStyle); } /* //These functions have been replaced by SetMarkerStyle() function this.SetMarkerSize = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_marker_flash_ID, "MARKER_SIZE", strValue); } this.SetMarkerColor = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_marker_flash_ID, "MARKER_COLOR", strValue); } this.SetFont = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_marker_flash_ID, "FONT", strValue); } this.SetFontColor = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_marker_flash_ID, "FONT_COLOR", strValue); } */ this.SetLabel = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_layer_flash_ID, this.m_marker_flash_ID, "LABEL", strValue); } this.SetContent = function (strValue) { this.m_flashObject.SetMarkerAttribute(this.m_layer_flash_ID, this.m_marker_flash_ID, "CONTENT", strValue); } this.SetGroundTileStyle = function ( strStyle ) { this.m_flashObject.SetGroundTileStyle(this.m_layer_flash_ID, this.m_marker_flash_ID, strStyle); } } function TGroundTile( flashObject, layer_flash_ID, marker_flash_ID ) { if (flashObject == null || layer_flash_ID == null || layer_flash_ID.toString().length == 0 || marker_flash_ID == null || marker_flash_ID.toString().length == 0 ) { TErrorMsg("Errro: the flashObject, Layer_flash_id or marker_flash_ID should not be null"); } this.m_flashObject = flashObject; this.m_layer_flash_ID = layer_flash_ID; this.m_marker_flash_ID = marker_flash_ID; this.SetVisible = function( bool ) { this.m_flashObject.SetMarkerVisibility(this.m_layer_flash_ID, this.m_marker_flash_ID,bool ); } this.SetGroundTileStyle = function ( strStyle ) { this.m_flashObject.SetGroundTileStyle(this.m_layer_flash_ID, this.m_marker_flash_ID, strStyle); } } ////////////////////////////////////////// // the definition of the polygon; function TPolygon( flashObject ,layer_flash_ID, polygon_flash_ID ) { if (flashObject == null || layer_flash_ID == null || layer_flash_ID.toString().length == 0 || polygon_flash_ID == null || polygon_flash_ID.toString().length == 0 ) { TErrorMsg("Errro: the flashObject, Layer_flash_id or polygon_flash_ID should not be null"); } this.m_flashObject = flashObject; this.m_layer_flash_ID = layer_flash_ID; this.m_polygon_flash_ID = polygon_flash_ID; this.MoveTo = function(latitude, longitude) { this.m_flashObject.MovePolygonTo(this.m_layer_flash_ID, this.m_polygon_flash_ID, latitude, longitude); } this.MoveToAni = function(latitude, longitude, speed, moveEndCallback) { var strGlobalFunctor = FunctorGlobalize( moveEndCallback ); this.m_flashObject.MovePolygonToAni(this.m_layer_flash_ID, this.m_polygon_flash_ID, latitude, longitude, speed, strGlobalFunctor); } this.SetOnClickListener = function(callbackFunction) { var strGlobalFunctor = FunctorGlobalize( callbackFunction ); this.m_flashObject.SetPolygonOnClickListener( this.m_layer_flash_ID, this.m_polygon_flash_ID, strGlobalFunctor ); } this.UpdateStyle = function( styleStr ) { this.m_flashObject.ModifyPolygonStyle( this.m_layer_flash_ID, this.m_polygon_flash_ID, styleStr); } } ////////////////////////////////////////// // the definition of the TContent Class; function TTabObject(tab_label, tab_content) { if (tab_label == null || tab_content == null) { TErrorMsg("Errro: the flashObject, content_flash_ID should not be null"); } //this.m_flashObject = flashObject; this.m_tab_label = tab_label; this.m_tab_content = tab_content; } function GetContentString(myContent) { if( (typeof(myContent) == "object") ) { isArray = true; for(i in myContent) { if( typeof(myContent[i]) == "string" ) { isArray = false; break; } } contentStr = ""; if(isArray == true) { //this is an array of tab objects for(i in myContent) { contentStr = contentStr + escape(myContent[i].m_tab_label) + "," + escape(myContent[i].m_tab_content); if(i<(myContent.length -1)) { contentStr+=";" } } } else { //this is a tab object contentStr = escape(myContent.m_tab_label) + "," + escape(myContent.m_tab_content); } return contentStr; } else { TErrorMsg("Error: Data type mistake of TabObject"); } } ///////////////////////////////////////////////////////////////////////////////////// /* the global functions of API */ function TGetBrowserType() { var userAgent = navigator.userAgent.toLowerCase(); var browser = "unknown"; var version = -1; if(/webkit/.test( userAgent )) { browser = "safari"; version = (userAgent.match( /.+(?:version)[\/]([\d.]+)/ ) || [])[1]; } if(/opera/.test( userAgent )) { browser = "opera"; version = (userAgent.match( /.+(?:ra)[\/]([\d.]+)/ ) || [] )[1]; } if(/msie/.test( userAgent ) && !/opera/.test( userAgent )) { browser = "msie"; version = (userAgent.match( /(?:ie)[ ]([\d.]+)/ ) || [] )[1]; } if(/firefox/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)) { browser = "firefox"; version = (userAgent.match( /.+(?:firefox)[\/]([\d.]+)/ ) || [] )[1]; } if(/mozilla/.test(userAgent)&&!/(compatible|webkit)/.test(userAgent)&&!/(compatible|firefox)/.test(userAgent)) { browser = "mozilla"; version = (userAgent.match( /.+(?:la)[\/]([\d.]+)/ ) || [] )[1]; } var obj = new Object(); obj.type = browser; obj.version = version; return obj; } function TBrowserIsCompatible() { var isCompatible = true; var OSName="Unknown OS"; if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS"; if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; //document.write('Your OS: '+OSName); var agent=navigator.userAgent.toLowerCase(); var is_iphone = (agent.indexOf('iphone') != (-1)); if (is_iphone) { isCompatible = false; //document.write('Your device is iPhone'); } return isCompatible; } // out put error message. function TErrorMsg( errorMessage ) { // TODO: add more styles of message box //alert( errorMessage ); } /********************************************************* // the internal functions // *****************************************************/ /* function _Internal_OnMapPreLoad() { // alert("on map load" + map0); timerID = setTimeout("onMapLoad()", 20); // intentionally delay for waiting the flash to be loaded. } */ ///////////////////////////////////////////////////////////////////////////////////// /* the global functions of API */ // JScript File //var g_http_request = new Array(); //var g_http_callbackFun = new Array(); //var g_RequestID = 0; function TDownloadRequest( urlToDownload, onAsynLoadedcallbackFunction, requestID) { //alert("TDownloadRequest called.") var http_request = null; var browser = TGetBrowserType(); if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); // BroswerType = "OTHER"; if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE // BroswerType = "IE"; try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { http_request = false; } } } if (! http_request) { //alert('Cannot create XMLHTTP instance'); return false; } // these two local var for the function _InternalOnDataLoad only //var requestIDLocal = g_RequestID; var http_requestLocal = http_request; var callbackFunLocal = onAsynLoadedcallbackFunction; var _InternalOnDataLoad = function() { //if (g_http_request[requestIDLocal].readyState == 4) if (http_requestLocal.readyState == 4) { //g_http_callbackFun[requestIDLocal]( http_requestLocal, http_requestLocal.status ); callbackFunLocal(http_requestLocal, http_requestLocal.status, requestID); //his.m_onLoadedcallbackFunction( this.m_http_request, this.m_http_request.status ); //this.m_http_request = null; // g_http_request[ requestIDLocal ] = null; http_requestLocal = null; } else { //alert( "state:" + http_request.readyState); // 0: not initialized. // 1: connection established. // 2: request received. // 3: answer in process. // 4: finished. } } http_request.onreadystatechange = _InternalOnDataLoad; //g_http_request[this.requestID] = http_request; this.m_http_request = http_request; this.Send = function() { this.m_http_request.open('GET', urlToDownload, true); this.m_http_request.send(null); } this.Abort = function() { this.m_http_request.abort(); } } var g_globalFunctorArray = new Array(); var g_globalID = 0; function FunctorGlobalize( functor ) { var ID_Functor = "ID_Functor_" + ( g_globalID ); g_globalID++; // debugger; g_globalFunctorArray[ID_Functor] = functor; return "g_globalFunctorArray[\"" + ID_Functor + "\"]"; } // !!! ??? Attention please We did not remove the Tag currently . // TODO: we need to remove TAG Script in the GeoCodeService_JS_ ASP file. var g_GeoCode_ID = 0; function GetGeoCodeID() { return g_GeoCode_ID++; } //debugger; var g_headElement = null; function TGetLatLngByAddress( addressFull, GeocodeCallBackFunctor) { var strGlobalFunctor = FunctorGlobalize(GeocodeCallBackFunctor); var strServer = "http://tfservice.cs.fiu.edu/coordinatebyadd/Default.aspx?"; var url = strServer; url = url + "street=" + encodeURIComponent( addressFull ) + ""; url = url + "&CallBackFun=" + encodeURIComponent( strGlobalFunctor ); var ScriptID = "GeoCodeService_JS_ID_" + GetGeoCodeID(); url= url + ("&SCRIPT_ID=" + ScriptID);// some thing interesting g_headElement = document.getElementsByTagName("HEAD").item(0); if ( g_headElement == null ) { TErrorMsg("Runtime Error: the page should contain at least one DOM element!"); } var script = document.createElement("SCRIPT"); script.src = url; script.defer = true; script.type = "text/javascript"; script.id = ScriptID; g_headElement.appendChild(script); } function TGetLatLngByAddressEx(addressFull, GeocodeCallBackFunctor, latitude, longitude, resolution) { var strGlobalFunctor = FunctorGlobalize(GeocodeCallBackFunctor); var strServer = "http://tfservice.cs.fiu.edu/coordinatebyadd/stage/DefaultEx.aspx?"; var url = strServer; url = url + "street=" + encodeURIComponent(addressFull) + "&CallBackFun=" + encodeURIComponent(strGlobalFunctor) + "&latitude=" + latitude + "&longitude=" + longitude + "&resolution=" + resolution; var ScriptID = "GeoCodeService_JS_ID_" + GetGeoCodeID(); url = url + ("&SCRIPT_ID=" + ScriptID); // //window.open(url); g_headElement = document.getElementsByTagName("HEAD").item(0); if (g_headElement == null) { TErrorMsg("Runtime Error: the page should contain at least one DOM element!"); } var script = document.createElement("SCRIPT"); script.src = url; script.defer = true; script.type = "text/javascript"; script.id = ScriptID; g_headElement.appendChild(script); } function TGetLevelByResolution( resolution ) { var ZoomLevels = new Array(); //LatlongData ZoomLevels[0] = 78271.5170; ZoomLevels[1] = 39135.7585; ZoomLevels[2] = 19567.8792; ZoomLevels[3] = 9783.9396; ZoomLevels[4] = 4891.9698; ZoomLevels[5] = 2445.9849; ZoomLevels[6] = 1222.9925; ZoomLevels[7] = 611.4962; ZoomLevels[8] = 305.7481; ZoomLevels[9] = 152.8741; // UTMData ZoomLevels[10] = 76.8; ZoomLevels[11] = 38.4; ZoomLevels[12] = 19.2; ZoomLevels[13] = 9.6; ZoomLevels[14] = 4.8; ZoomLevels[15] = 2.4; ZoomLevels[16] = 1.2; ZoomLevels[17] = 0.6; ZoomLevels[18] = 0.3; ZoomLevels[19] = 0.15; ZoomLevels[20] = 0.075; var maxlevels = 21; var sqrt2 = 1.41421356 var tolerance = 0.0001 if (resolution < ZoomLevels[20]/ sqrt2) { return 21; } if (resolution > ZoomLevels[0]* sqrt2) { return 1; } var i = 0; for ( i = 0; i < maxlevels; i++ ) { if ( ( resolution >= (ZoomLevels[i]/sqrt2 ) )&&( resolution < ZoomLevels[i]*sqrt2 + tolerance ) ) { return i+1; } } } function TGetResolutionByLevel( level ) { var ZoomLevels = new Array(); //LatlongData ZoomLevels[0] = 78271.5170; ZoomLevels[1] = 39135.7585; ZoomLevels[2] = 19567.8792; ZoomLevels[3] = 9783.9396; ZoomLevels[4] = 4891.9698; ZoomLevels[5] = 2445.9849; ZoomLevels[6] = 1222.9925; ZoomLevels[7] = 611.4962; ZoomLevels[8] = 305.7481; ZoomLevels[9] = 152.8741; // UTMData ZoomLevels[10] = 76.8; ZoomLevels[11] = 38.4; ZoomLevels[12] = 19.2; ZoomLevels[13] = 9.6; ZoomLevels[14] = 4.8; ZoomLevels[15] = 2.4; ZoomLevels[16] = 1.2; ZoomLevels[17] = 0.6; ZoomLevels[18] = 0.3; ZoomLevels[19] = 0.15; ZoomLevels[20] = 0.075; if ( (level == null) || (!( level >= 1 && level < 22 )) ) { //alert("This resolution is not correctly provided."); return; } level = Math.floor( level ); return ZoomLevels[ level - 1 ]; } function TAddressReturnObject (address,housenumber,range_from,range_to,street,city,state,zip,latitude,longitude,distance,compass_direction,offset,streetc) { this.address=address; this.housenumber=housenumber; this.range_from=range_from; this.range_to=range_to; this.street=street; this.city=city; this.state=state; this.zip=zip; this.latitude=latitude; this.longitude=longitude; this.distance=distance; this.compass_direction=compass_direction; this.offset=offset; this.streetc=streetc; if(this.distance<=10){ this.GGeoAddressAccuracy=9; } else if(this.distance>10 && this.distance<=50) { this.GGeoAddressAccuracy=8; } else if(this.distance>50 && this.distance<=100) { this.GGeoAddressAccuracy=7; } else if(this.distance>100 && this.distance<=200) { this.GGeoAddressAccuracy=6; } else if(this.distance>200 && this.distance<=500) { this.GGeoAddressAccuracy=5; } else if(this.distance>500) { this.GGeoAddressAccuracy=4; } this.toString = function() { var addressString = this.address+", "+this.city+", "+this.state+", "+this.zip; if(addressString==null) throw("Error"); return addressString ; } this.GetAccuracyDescriptioin = function (GGeoAddressAccuracy) { switch(this.GGeoAddressAccuracy) { case 9: return "Premise level accuracy"; break; case 8: return "Address level accuracy"; break; case 7: return "Intersection level accuracy"; break; case 6: return "Street level accuracy"; break; case 5: return "Post code (zip code) level accuracy"; break; case 4: return "Town (city, village) level accuracy"; break; case 3: return "Sub-region (county, municipality, etc.) level accuracy"; break; case 2: return "Region (state, province, prefecture, etc.) level accuracy"; break; case 1: return "Country level accuracy"; break; case -1: return "Unknown location"; break; } } } // - start of get address by lat and lng - function TGetAddressesByLatLngPro( Lat, Lng, ReverseGeocodeCallBackFunctor) { var strGlobalFunctor = FunctorGlobalize(ReverseGeocodeCallBackFunctor); var strServer = "http://tfservice.cs.fiu.edu/AddByCoordinate/Default.aspx?"; var url = strServer; url = url + "Lat=" + encodeURIComponent( Lat ) + ""; url = url + "&Lng=" + encodeURIComponent( Lng ) + ""; url = url + "&CallBackFun=" + encodeURIComponent( strGlobalFunctor ); var ScriptID = "GeoCodeService_JS_ID_" + GetGeoCodeID(); url= url + ("&SCRIPT_ID=" + ScriptID); g_headElement = document.getElementsByTagName("HEAD").item(0); if ( g_headElement == null ) { TErrorMsg("Runtime Error: the page should contain at least one DOM element!"); } var script = document.createElement("SCRIPT"); script.src = url + "&a=" + Math.random(); script.defer = true; script.type = "text/javascript"; script.id = ScriptID; g_headElement.appendChild(script); } function TGetAddressByLatLng( Lat, Lng, ReverseGeocodeCallBackFunctor) { var strGlobalFunctor = FunctorGlobalize(ReverseGeocodeCallBackFunctor); var strServer = "http://tfservice.cs.fiu.edu/AddByCoordinate/Compact.aspx?"; var url = strServer; url = url + "Lat=" + encodeURIComponent( Lat ) + ""; url = url + "&Lng=" + encodeURIComponent( Lng ) + ""; url = url + "&CallBackFun=" + encodeURIComponent( strGlobalFunctor ); var ScriptID = "GeoCodeService_JS_ID_" + GetGeoCodeID(); url= url + ("&SCRIPT_ID=" + ScriptID); g_headElement = document.getElementsByTagName("HEAD").item(0); if ( g_headElement == null ) { TErrorMsg("Runtime Error: the page should contain at least one DOM element!"); } var script = document.createElement("SCRIPT"); script.src = url + "&a=" + Math.random(); script.defer = true; script.type = "text/javascript"; script.id = ScriptID; g_headElement.appendChild(script); } // - End of LatLng to address - function number_clip(original, minValue, maxValue) { var safeValue; safeValue = (original >= minValue)?original : minValue; safeValue = (safeValue <= maxValue)?safeValue : maxValue; return safeValue; }