c#两种方式调用google地球,调用COM API以及调用GEPLUGIN 与js交互,加载kml文件,dae文件。将二维高德地图覆盖到到三维谷歌地球表面。
网络上资源很多不全面,自己在开发的时候走了不少弯路,在这里整理了最全面的google全套开发,com交互,web端交互。封装好了各种模块功能。 直接就可以调用。
第一种方式:调用comapi实现调用google地球
1、安装googleearth客户端。传送门:https://pan.baidu.com/s/1xi3fwciy3jt6t5xbypqpcg 提取码:0l7u
2、添加引用using earthlib;如果找不到此dll,到googleearth的安装目录下寻找后添加到引用即可。
3、添加预定义的方法到项目中,后续获取窗口句柄,以及设置窗口的时候会调用其中的一些方法。
class nativemethods { [dllimport("user32.dll", charset = charset.auto, setlasterror = true)] public static extern bool setwindowpos(intptr hwnd, intptr hwndinsertafter, int x, int y, int cx, int cy, uint32 uflags); [dllimport("user32.dll", charset = charset.auto)] public static extern intptr postmessage(int hwnd, int msg, int wparam, int lparam); #region 预定义 public static readonly intptr hwnd_bottom = new intptr(1); public static readonly intptr hwnd_notopmost = new intptr(-2); public static readonly intptr hwnd_top = new intptr(0); public static readonly intptr hwnd_topmost = new intptr(-1); public static readonly uint32 swp_nosize = 1; public static readonly uint32 swp_nomove = 2; public static readonly uint32 swp_nozorder = 4; public static readonly uint32 swp_noredraw = 8; public static readonly uint32 swp_noactivate = 16; public static readonly uint32 swp_framechanged = 32; public static readonly uint32 swp_showwindow = 64; public static readonly uint32 swp_hidewindow = 128; public static readonly uint32 swp_nocopybits = 256; public static readonly uint32 swp_noownerzorder = 512; public static readonly uint32 swp_nosendchanging = 1024; #endregion public delegate int enumwindowsproc(intptr hwnd, int lparam); [dllimport("user32", charset = charset.auto)] public extern static intptr getparent(intptr hwnd); [dllimport("user32", charset = charset.auto)] public extern static bool movewindow(intptr hwnd, int x, int y, int nwidth, int nheight, bool brepaint); [dllimport("user32", charset = charset.auto)] public extern static intptr setparent(intptr hwndchild, intptr hwndnewparent); [dllimport("user32.dll", exactspelling = true, charset = charset.auto)] public static extern intptr getwindow(intptr hwnd, int ucmd); public static int gw_child = 5; public static int gw_hwndnext = 2; }
4、定义变量
private bool isgestart = false;//ge是否开启 private applicationgeclass geapp; /// <summary> /// 用来关闭googleearth的消息定义 /// </summary> static readonly int32 wm_quit = 0x0012; private intptr gehwnd = (intptr)5; private intptr gehrender = (intptr)5; private intptr geparenthrender = (intptr)5;
5、做完上面的工作后,开始初始化谷歌地球。将下列代码放入自己定义的方法中即可。
try { if (!this.designmode) { geapp = new applicationgeclass(); gehwnd = (intptr)geapp.getmainhwnd(); //隐藏googleearth主窗口 nativemethods.setwindowpos(gehwnd, nativemethods.hwnd_bottom, 0, 0, 0, 0, nativemethods.swp_nosize + nativemethods.swp_hidewindow); gehrender = (intptr)geapp.getrenderhwnd(); geparenthrender = (intptr)nativemethods.getparent(gehrender); //将渲染窗口嵌入到主窗体 nativemethods.movewindow(gehrender, 0, 0, this.panelex_google.size.width, this.panelex_google.size.height, true); nativemethods.setparent(gehrender, this.panelex_google.handle); isgestart = true; } } catch (exception ex) { isgestart = false; thread.sleep(1000); }
6、以上代码可加载谷歌地球,并且释放资源,程序运行如图:
第一种方式实质上是启动googleearth客户端,并获取窗口句柄,再将窗口显示的自己定义的控件下面,此种方法也可以实现需求,但是经过测试,此方法存在两大弊端。第一,在启动谷歌地球的时候将占用大量的cpu资源。第二、在释放谷歌地球的时候时候,可能会释放失败,无法关闭googleearth此时也将占用大量的cpu。基于以上弊端所以采用第二种方式。webroswer调用js。
2、重点:干货。
c#使用geplugin插件,webroswer与js交互,实现web端的googleearth体验。并且加载kml,加载三维模型dae,加载路径,电子围栏。各种功能已封装。调用即可使用。
1、下载geplugin 传送门:
链接:https://pan.baidu.com/s/1e_elo_x0klhffgnzbboa6w
提取码:687b
2、使用geplugin相对于comapi要较为复杂。但是性能最优。下载封装好的文件,单独的exe,放在程序项目文件中,启动这个文件,在程序中调用一个方法即可加载google地球到webroswer。因为这个文件有公司logo。所以不便发布于此,有想要的可以私信我。单独发送。谨记:此文件只供学习使用,交流心得,不得用于任何商业行为。
3、下面开始正式的编码。如果下载了exe的文件,并且打开后,执行此段代码,谷歌地球将被加载完成。获取的硬盘id以及cpu序列号,将此数据传递到封装好的服务中。防止别的浏览器直接输入网址浏览。安全校验使用。
并且将你的form设置成对com可见
[comvisible(true)] public partial class analysisform : form
private cassinidev.server _server1;
private bool iswebserverstarted = false;
public string webserver_path;
private void navigateanaform_shown() { string plugin_url_local; string plugin_url_reload; //googleearth延时加载的线程 //在程序启动时使用单独的线程来加载webbroswer控件中的ge地图,以免出现主界面加载时卡顿的现象 thread gelazyloadingthread = new system.threading.thread(new system.threading.threadstart(delegate () { //thread.sleep(50); //记录系统中现有的geplugin线程 process[] listexistedgepluginprocess = process.getprocessesbyname("geplugin"); this.begininvoke( new action(() => { plugin_url_local = "http://127.0.0.1:9809/map.asp?px1=" + getcpuid() + "&px2=" + getdiskid(); plugin_url_reload = "http://127.0.0.1:9808/reload.html"; this.webbrowserge.objectforscripting = this; this.webbrowserge.scripterrorssuppressed = false ; //_server = new cassinidev.server(9630, "/", webserver_path, //"g:\\desktop\\1111\\bin\\debug\\navfiles", // system.net.ipaddress.parse("127.0.0.1"), "", false, true); //http://127.0.0.1:9809/map.asp?px1=178bfbff00810f10&px2=gloway stk720gs3-s7 //http://192.168.0.196:9808/map.asp?px1=bfebfbff000906e9&px2=sandisk cruzer glide 3.0 usb device this.webbrowserge.navigate(plugin_url_local); this.webbrowserge.visible = true; } )); })); //启动googleearth装载的线程 gelazyloadingthread.setapartmentstate(apartmentstate.sta); gelazyloadingthread.start(); }
private string getdiskid()
{
try
{
//获取硬盘id
string hdid = " ";
managementclass mc = new managementclass("win32_diskdrive");
managementobjectcollection moc = mc.getinstances();
foreach (managementobject mo in moc)
{
hdid = (string)mo.properties["model"].value;
}
moc = null;
mc = null;
return hdid;
}
catch
{
return "unknown";
}
finally
{
}
}
private string getcpuid()
{
try
{
//获取cpu序列号代码
string cpuinfo = " ";//cpu序列号
managementclass mc = new managementclass("win32_processor");
managementobjectcollection moc = mc.getinstances();
foreach (managementobject mo in moc)
{
cpuinfo = mo.properties["processorid"].value.tostring();
}
moc = null;
mc = null;
return cpuinfo;
}
catch
{
return "unknown";
}
finally
{
}
}
4、此时地图即可加载完成,万水千山,踏出第一步。但是此时无法向谷歌地球添加kml或者三维模型。和一些其他的操作。如果要加载kml文件。继续往下看。
5、此时启动web容器 ,先添加引用 cassinidev4-lib;找不到又不想下载? 传送门来了:
链接:https://pan.baidu.com/s/1lozd7plvagg3nstmeeub0g
提取码:oymj
/// <summary> /// 启动web容器服务 /// </summary> public void start_webserver() { webserver_path = string.concat(new object[] { directory.getcurrentdirectory(), path.directoryseparatorchar, "3dview" }); _server1 = new cassinidev.server(9630, "/", webserver_path, system.net.ipaddress.parse("127.0.0.1"), "", false, true); if (!iswebserverstarted) { try { _server1.start(); iswebserverstarted = true; messagebox.show("web 服务已经打开!"); } catch (exception ex) { messagebox.show( "服务打开失败!", "信息提示", messageboxbuttons.ok, messageboxicon.error); _server1.dispose(); return; } /* try { _server2.start(); iswebserverstarted = true; } catch (exception ex) { xtramessagebox.show(program.devexpressdarkskin, "gbq服务2打开失败!", "信息提示", messageboxbuttons.ok, messageboxicon.error); _server2.dispose(); return; } */ } else { try { _server1.shutdown(); iswebserverstarted = false; } catch (exception ex) { messagebox.show( "服务关闭失败!", "信息提示", messageboxbuttons.ok, messageboxicon.error); _server1.dispose(); //return; } try { _server1.start(); iswebserverstarted = true; } catch (exception ex) { messagebox.show( "服务打开失败!", "信息提示", messageboxbuttons.ok, messageboxicon.error); _server1.dispose(); return; } } }
6、此时小伙伴要问,为什么要启动一个web服务,不要着急,往下看。加载kml文件。
webbrowserge.document.invokescript("importlidarkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/zouhang1.kml",true });
是不是很神奇,只需要一行代码,你的kml文件,或者kml文件中带有有三维模型的文件,即可被加载成功,因为程序已经完全封装了你所需要的功能。
解析上一个疑惑,为什么要启动一个web服务,因为invokescprit加载文件的时候需要以网址的形式加载,所以启动一个web服务器,并设置好root目录,将你的kml文件放置到root目录下即可。
7、你以为此时kml文件就可以加载成功了?成功的道路总是充满坎坷的。此时的你加载kml的时候,应该是看不到任何反应的。因为我当初在这个地方踩了很多的坑。你们很幸运,不需要在这里挣扎。记录一下。分享给你们。
///重要重要重要
public string getmapserverandlag_callback() { return "7,1,18"; }
多么简单的一个方法,但是没有他你什么也做不了。这个是地图加载后的回调方法。务必加上。用于给层级赋值。
下面还有几个方法,分享给你门,可有可无。
//加载失败后的回调函数
public void jsinitfailurecallback_(string error){
}
//加载成功后的回调函数
public void gesuccessloadedcallback_()
{
}
8、经过以上的努力你已经达成了目标的80%了。你所想要的功能已经基本实现。
另外一些其他的加载方法在这里附上
webbrowserge.document.invokescript("importgooglemapkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/ditu.kml" }); webbrowserge.document.invokescript("importlidarkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/zouhang1.kml",true }); webbrowserge.document.invokescript("importremarkkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/1111.kml" }); webbrowserge.document.invokescript("importdrawkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/1111.kml" }); webbrowserge.document.invokescript("importlidarkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/1111.kml", true }); webbrowserge.document.invokescript("importdrawkmlfilebyurl", new object[] { "http://192.168.1.196:9630/3dpaint/kmldrawings/1111.kml", true }); webbrowserge.document.invokescript("searchlocation_e", new object[] { 38, 117 }); webbrowserge.document.invokescript("importlidarkmlfilebyurl", new object[] { "http://127.0.0.1:9630/3dmap/111.kml" }); webbrowserge.document.invokescript("getgekml_e"); webbrowserge.document.invokescript("setmaplayersstatus", new object[] { false, false, false, false, false, false, false, false, false, false, false, false });
非常简单,可自己摸索。
9、上图
到这里就结束了?不存在的。技术用于之境。下面分享给大家,如何将二维高德地图蒙皮到三维谷歌球体上。拭目以待。
10、加载高德地图到谷歌地球上。实现谷歌地球与高德地图之间的切换。
首先。需要下载两个坐标转换文件。传送门:
链接:https://pan.baidu.com/s/18qcxtxdx98nj-gkg5wu6_w
提取码:b9c9
//此文件是实现坐标以及经纬度的转换
<%@ import namespace="system.web.httpresponse" %> <%@ language="javascript" debug="true"%> <% function downloadfile() { var xvalue=request.querystring("x") var yvalue=request.querystring("y") var zvalue=request.querystring("z") var filename="landun_"+ zvalue*1+"_"+xvalue*1+"_"+yvalue*1+".kml" var kmlstring=getkmlsrtring() response.addheader("content-disposition", "attachment;filename="+filename+";") response.contenttype = "text/xml" response.write(kmlstring) response.flush response.clear } //生成kml文件的内容 function getkmlsrtring() { var xvalue=request.querystring("x") var yvalue=request.querystring("y") var zvalue=request.querystring("z") var kmlstr="<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">" ///getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"y"); ///getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1+1,"y") ///getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1,"x") ///getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"x") if(zvalue*1>=21) { kmlstr=kmlstr+"<document>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<groundoverlay>\r\n" kmlstr=kmlstr+"<draworder>1</draworder>\r\n<icon>\r\n<href>http://wprd04.is.autonavi.com/appmaptile</href><httpquery>&lang=zh_cn&size=1&scl=1&style=7&x="+(xvalue*1)+"&y="+(yvalue*1)+"&z="+(zvalue*1)+"&</httpquery></icon>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"x")+"</west>\r\n</latlonaltbox>\r\n<altitudemode>clamptoground</altitudemode>\r\n<altitude>0</altitude>\r\n" kmlstr=kmlstr+"</groundoverlay>\r\n</document>\r\n</kml>" }else{ kmlstr=kmlstr+"<document>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<networklink>\r\n" kmlstr=kmlstr+"<name>"+(xvalue*2)+"_"+(yvalue*2)+"_"+(zvalue*1+1)+"</name>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<link>\r\n" kmlstr=kmlstr+"<href>http://127.0.0.1:9630/3dmap/ditu.aspx</href><httpquery>mt=ditu&x="+(xvalue*2)+"&y="+(yvalue*2)+"&z="+(zvalue*1+1)+"&v=1.7&dx=0&dy=0&trans=0</httpquery>\r\n</link>\r\n</networklink>\r\n" kmlstr=kmlstr+"<networklink>\r\n<name>"+(xvalue*2+1)+"_"+(yvalue*2)+"_"+(zvalue*1+1)+"</name>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+2,yvalue*2,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<link>\r\n" kmlstr=kmlstr+"<href>http://127.0.0.1:9630/3dmap/ditu.aspx</href><httpquery>mt=ditu&x="+(xvalue*2+1)+"&y="+(yvalue*2)+"&z="+(zvalue*1+1)+"&v=1.7&dx=0&dy=0&trans=0</httpquery>\r\n</link>\r\n</networklink>\r\n" kmlstr=kmlstr+"<networklink>\r\n<name>"+(xvalue*2)+"_"+(yvalue*2+1)+"_"+(zvalue*1+1)+"</name>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2+1,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2+2,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2+1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1+1,xvalue*2,yvalue*2+1,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<link>\r\n" kmlstr=kmlstr+"<href>http://127.0.0.1:9630/3dmap/ditu.aspx</href><httpquery>mt=ditu&x="+(xvalue*2)+"&y="+(yvalue*2+1)+"&z="+(zvalue*1+1)+"&v=1.7&dx=0&dy=0&trans=0</httpquery>\r\n</link>\r\n</networklink>\r\n" kmlstr=kmlstr+"<networklink>\r\n<name>"+(xvalue*2+1)+"_"+(yvalue*2+1)+"_"+(zvalue*1+1)+"</name>\r\n<region>\r\n<lod>\r\n<minlodpixels>256</minlodpixels>\r\n<maxlodpixels>-1</maxlodpixels>\r\n</lod>\r\n<latlonaltbox>\r\n" kmlstr=kmlstr+"<north>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2+1,"y"))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2+2,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+2,yvalue*2+1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1+1,xvalue*2+1,yvalue*2+1,"x")+"</west>\r\n</latlonaltbox>\r\n</region>\r\n<link>\r\n" kmlstr=kmlstr+"<href>http://127.0.0.1:9630/3dmap/ditu.aspx</href><httpquery>mt=ditu&x="+(xvalue*2+1)+"&y="+(yvalue*2+1)+"&z="+(zvalue*1+1)+"&v=1.7&dx=0&dy=0&trans=0</httpquery>\r\n</link>\r\n</networklink>\r\n" kmlstr=kmlstr+"<groundoverlay>\r\n<draworder>1</draworder>\r\n<icon>\r\n" kmlstr=kmlstr+"<href>http://wprd04.is.autonavi.com/appmaptile</href><httpquery>&lang=zh_cn&size=1&scl=1&style=7&x="+(xvalue*1)+"&y="+(yvalue*1)+"&z="+(zvalue*1)+"&</httpquery>\r\n</icon>" kmlstr=kmlstr+"<latlonaltbox>\r\n<north>"+((getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"y")))+"</north>\r\n<south>"+(getmercatorcoordinates(zvalue*1,xvalue,yvalue*1+1,"y"))+"</south>\r\n<east>"+getmercatorcoordinates(zvalue*1,xvalue*1+1,yvalue*1,"x")+"</east>\r\n<west>"+getmercatorcoordinates(zvalue*1,xvalue*1,yvalue*1,"x")+"</west>\r\n</latlonaltbox>\r\n" kmlstr=kmlstr+"<altitudemode>clamptoground</altitudemode>\r\n<altitude>0</altitude>\r\n</groundoverlay>\r\n</document>\r\n</kml>" } return kmlstr; } //得到墨卡托坐标(双轴) function getmercatorcoordinates(zvalue,xoryvalue,yoryvalue, xory) { var xymercator={} //得到墨卡托坐标 xymercator.x=(-180+(360/(math.pow(2,zvalue)))*xoryvalue) xymercator.y=20037508.3427892 +(-40075016.6855784/(math.pow(2,zvalue)))*yoryvalue ///response.write("<script>alert('xymercator.x "+xymercator.x+" xymercator.y "+xymercator.y +"');</script>"); //根据墨卡托坐标转换为gps经纬度,再转换为火星坐标系经度或纬度 var latlon = getmarlatitudeandlongitude(xymercator, xory) ///response.write("<script>alert('xory "+xory+ " latlon "+latlon+"');</script>"); return latlon } //返回修正后的经度或纬度 function getmarlatitudeandlongitude(xymercator, xory) { var y var longitudeandlatitude={} //此处需注意longitudeandlatitude.lng不需要再进行计算转换,直接赋值即可 longitudeandlatitude.lng = xymercator.x y=xymercator.y / 20037508.3427892 * 180 longitudeandlatitude.lat=(180 / math.pi * (2 * math.atan(math.exp(y * math.pi / 180)) - math.pi / 2))//.tofixed(12) ///response.write("<script>alert('longitudeandlatitude.lat"+longitudeandlatitude.lat+ " longitudeandlatitude.lng"+longitudeandlatitude.lng+"');</script>"); //转换gps经纬度为火星经纬度 var mar = transform(longitudeandlatitude.lat, longitudeandlatitude.lng) if(xory=="y") { return mar.mglat; } else { return mar.mglon } } //此方法已启用 //获取经纬度,墨卡托坐标转换为经纬度 function getlatitudeandlongitude(mercatory) { var y,longitudeandlatitude y=mercatory / 20037508.3427892 * 180 longitudeandlatitude=(180 / math.pi * (2 * math.atan(math.exp(y * math.pi / 180)) - math.pi / 2))//.tofixed(12) return longitudeandlatitude } //gps经纬度转化为火星经纬度 function transform(wglat, wglon) { var lnglat={} if (outofchina(wglat, wglon)) { lnglat.mglat = wglat; lnglat.mglon = wglon; return lnglat; } var dlat = transformlat(wglon - 105.0, wglat - 35.0); var dlon = transformlon(wglon - 105.0, wglat - 35.0); var radlat = wglat / 180.0 * math.pi; var magic = math.sin(radlat); magic = 1 - 0.00669342162296594323 * magic * magic; var sqrtmagic = math.sqrt(magic); dlat = (dlat * 180.0) / ((6378245.0 * (1 - 0.00669342162296594323)) / (magic * sqrtmagic) * math.pi); dlon = (dlon * 180.0) / (6378245.0 / sqrtmagic * math.cos(radlat) * math.pi); lnglat.mglat = wglat - dlat; ///response.write("<script>alert('wglat"+wglat+ " dlat"+dlat+"lnglat.mglat "+lnglat.mglat+"');</script>"); lnglat.mglon = wglon - dlon; return lnglat; } //是否不在中国 function outofchina(lat, lon) { if (lon < 72.004 || lon > 137.8347) return true; if (lat < 0.8293 || lat > 55.8271) return true; return false; } //转换纬度 function transformlat(x, y) { var ret ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * math.sqrt(math.abs(x)); ret += (20.0 * math.sin(6.0 * x * math.pi) + 20.0 * math.sin(2.0 * x * math.pi)) * 2.0 / 3.0; ret += (20.0 * math.sin(y * math.pi) + 40.0 * math.sin(y / 3.0 * math.pi)) * 2.0 / 3.0; ret += (160.0 * math.sin(y / 12.0 * math.pi) + 320 * math.sin(y * math.pi / 30.0)) * 2.0 / 3.0; return ret; } //转换经度 function transformlon(x, y) { var ret ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * math.sqrt(math.abs(x)); ret += (20.0 * math.sin(6.0 * x * math.pi) + 20.0 * math.sin(2.0 * x * math.pi)) * 2.0 / 3.0; ret += (20.0 * math.sin(x * math.pi) + 40.0 * math.sin(x / 3.0 * math.pi)) * 2.0 / 3.0; ret += (150.0 * math.sin(x / 12.0 * math.pi) + 300.0 * math.sin(x / 30.0 * math.pi)) * 2.0 / 3.0; return ret; } %> <%downloadfile()%>
<?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <networklink> <name>google ditu (china maps)</name> <region> <latlonaltbox> <north>85.051128779807</north> <south>-85.051128779807</south> <east>180</east> <west>-180</west> </latlonaltbox> <lod> <minlodpixels>256</minlodpixels> <maxlodpixels>-1</maxlodpixels> </lod> </region> <link> <href>http://127.0.0.1:9630/3dmap/ditu.aspx</href><httpquery>mt=ditu&x=0&y=0&z=0&v=1.7&dx=0&dy=0&trans=0</httpquery> <viewrefreshmode>onregion</viewrefreshmode> </link> </networklink> </kml>
只需向普通地图一样,直接加载下载好的,ditu.kml文件一样,即可实现从谷歌地球切换到高德地图。
有图有真相
附上一些附加的文件js文件。供参考研究。再次申明,只可用于技术学习,不可用于商业行为,谨记!!!
if (!window['googlelt_']) {
window['googlelt_'] = (new date()).gettime();
}
if (!window['google']) {
window['google'] = {};
}
if (!window['google']['loader']) {
window['google']['loader'] = {};
google.loader.servicebase = 'http://www.google.com/uds';
google.loader.googleapisbase = 'http://ajax.googleapis.com/ajax';
google.loader.apikey = 'abqiaaaa7wgf96hesauuovt92hvlgrsco55h5l89yfkfbozyeht3olu9obq-iplpny04cibcfidwrhn8jortrg';
google.loader.keyverified = true;
google.loader.loadfailure = false;
google.loader.secure = false;
google.loader.googlelocale = 'www.google.com';
google.loader.clientlocation = {"latitude":31.8175,"longitude":117.22775,"address":{"city":"hefei","region":"anhui","country":"china","country_code":"cn"}};
google.loader.additionalparams = '';
//js匿名函数,js加载时立即执行
(function () {
var d = void 0,
g = !0,
h = null,
j = !1,
k = encodeuricomponent,
l = window,
m = document;
function n(a, b) {
return a.load = b
}
var p = "push",
q = "replace",
r = "charat",
t = "indexof",
u = "servicebase",
v = "name",
w = "gettime",
x = "length",
y = "prototype",
z = "settimeout",
a = "loader",
b = "substring",
c = "join",
d = "tolowercase";
function e(a) {
return a in f ? f[a] : f[a] = -1 != navigator.useragent[d]()[t](a)
}
var f = {};
function g(a, b) {
var c = function () {};
c.prototype = b[y];
a.t = b[y];
a.prototype = new c
}
function h(a, b, c) {
var e = array[y].slice.call(arguments, 2) || [];
return function () {
var c = e.concat(array[y].slice.call(arguments));
return a.apply(b, c)
}
}
function i(a) {
a = error(a);
a.tostring = function () {
return this.message
};
return a
}
function j(a, b) {
for (var c = a.split(/\./), e = l, f = 0; f < c[x] - 1; f++) e[c[f]] || (e[c[f]] = {}), e = e[c[f]];
e[c[c[x] - 1]] = b
}
function k(a, b, c) {
a[b] = c
}
if (!l) var l = j;
if (!m) var m = k;
google[a].v = {};
l("google.loader.callbacks", google[a].v);
var n = {},
o = {};
google[a].eval = {};
l("google.loader.eval", google[a].eval);
n(google, function (a, b, c) {
function e(a) {
var b = a.split(".");
if (2 < b[x]) throw i("module: '" + a + "' not found!");
"undefined" != typeof b[1] && (f = b[0], c.packages = c.packages || [], c.packages[p](b[1]))
}
var f = a,
c = c || {};
if (a instanceof array || a && "object" == typeof a && "function" == typeof a[c] && "function" == typeof a.reverse)
for (var i = 0; i < a[x]; i++) e(a[i]);
else e(a); if (a = n[":" + f]) {
c && (!c.language && c.locale) && (c.language = c.locale);
c && "string" == typeof c.callback && (i = c.callback, i.match(/^[[\]a-za-z0-9._]+$/) && (i = l.eval(i), c.callback =
i));
if ((i = c && c.callback != h) && !a.s(b)) throw i("module: '" + f + "' must be loaded before dom onload!");
i ? a.m(b, c) ? l[z](c.callback, 0) : a.load(b, c) : a.m(b, c) || a.load(b, c)
} else throw i("module: '" + f + "' not found!");
});
l("google.load", google.load);
google.s = function (a, b) {
b ? (0 == p[x] && (q(l, "load", r), !e("msie") && !e("safari") && !e("konqueror") && e("mozilla") || l.opera ? l.addeventlistener("domcontentloaded", r, j) : e("msie") ? m.write("<script defer onreadystatechange='google.loader.domready()' src=//:><\/script>") : (e("safari") || e("konqueror")) && l[z](t, 10)), p[p](a)) : q(l, "load", a)
};
l("google.setonloadcallback", google.s);
function q(a, b, c) {
if (a.addeventlistener) a.addeventlistener(b, c, j);
else if (a.attachevent) a.attachevent("on" + b, c);
else {
var e = a["on" + b];
a["on" + b] = e != h ? aa([c, e]) : c
}
}
function aa(a) {
return function () {
for (var b = 0; b < a[x]; b++) a[b]()
}
}
var p = [];
google[a].o = function () {
var a = l.event.srcelement;
"complete" == a.readystate && (a.onreadystatechange = h, a.parentnode.removechild(a), r())
};
l("google.loader.domready", google[a].o);
var ba = {
loaded: g,
complete: g
};
function t() {
ba[m.readystate] ? r() : 0 < p[x] && l[z](t, 10)
}
function r() {
for (var a = 0; a < p[x]; a++) p[a]();
p.length = 0
}
google[a].d = function (a, b, c) {
if (c) {
var e;
"script" == a ? (e = m.createelement("script"), e.type = "text/javascript", e.src = b) : "css" == a && (e = m.createelement("link"), e.type = "text/css", e.href = b, e.rel = "stylesheet");
(a = m.getelementsbytagname("head")[0]) || (a = m.body.parentnode.appendchild(m.createelement("head")));
a.appendchild(e)
} else "script" == a ? m.write('<script src="' + b + '" type="text/javascript"><\/script>') : "css" == a && m.write('<link href="' + b + '" type="text/css" rel="stylesheet"></link>')
};
l("google.loader.writeloadtag", google[a].d);
google[a].p = function (a) {
o = a
};
l("google.loader.rfm", google[a].p);
google[a].r = function (a) {
for (var b in a) "string" == typeof b && (b && ":" == b[r](0) && !n[b]) && (n[b] = new u(b[b](1), a[b]))
};
l("google.loader.rpl", google[a].r);
google[a].q = function (a) {
if ((a = a.specs) && a[x])
for (var b = 0; b < a[x]; ++b) {
var c = a[b];
"string" == typeof c ? n[":" + c] = new v(c) : (c = new w(c[v], c.basespec, c.customspecs), n[":" + c[v]] = c)
}
};
l("google.loader.rm", google[a].q);
google[a].loaded = function (a) {
n[":" + a.module].l(a)
};
l("google.loader.loaded", google[a].loaded);
google[a].n = function () {
return "qid=" + ((new date)[w]().tostring(16) + math.floor(1e7 * math.random()).tostring(16))
};
l("google.loader.createguidarg_", google[a].n);
j("google_exportsymbol", j);
j("google_exportproperty", k);
google[a].a = {};
l("google.loader.themes", google[a].a);
google[a].a.h = "//www.google.com/cse/style/look/bubblegum.css";
m(google[a].a, "bubblegum", google[a].a.h);
google[a].a.j = "//www.google.com/cse/style/look/greensky.css";
m(google[a].a, "greensky", google[a].a.j);
google[a].a.i = "//www.google.com/cse/style/look/espresso.css";
m(google[a].a, "espresso", google[a].a.i);
google[a].a.l = "//www.google.com/cse/style/look/shiny.css";
m(google[a].a, "shiny", google[a].a.l);
google[a].a.k = "//www.google.com/cse/style/look/minimalist.css";
m(google[a].a, "minimalist", google[a].a.k);
google[a].a.m = "//www.google.com/cse/style/look/v2/default.css";
m(google[a].a, "v2_default", google[a].a.m);
function v(a) {
this.b = a;
this.o = [];
this.n = {};
this.e = {};
this.f = {};
this.j = g;
this.c = -1
}
v[y].g = function (a, b) {
var c = "";
b != d && (b.language != d && (c += "&hl=" + k(b.language)), b.nocss != d && (c += "&output=" + k("nocss=" + b.nocss)), b.nooldnames != d && (c += "&nooldnames=" + k(b.nooldnames)), b.packages != d && (c += "&packages=" + k(b.packages)), b.callback != h && (c += "&async=2"), b.style != d && (c += "&style=" + k(b.style)), b.noexp != d && (c += "&noexp=true"), b.other_params != d && (c += "&" + b.other_params));
if (!this.j) {
google[this.b] && google[this.b].jshash && (c += "&sig=" + k(google[this.b].jshash));
var e = [],
f;
for (f in this.n) ":" == f[r](0) && e[p](f[b](1));
for (f in this.e) ":" == f[r](0) && this.e[f] && e[p](f[b](1));
c += "&have=" + k(e[c](","))
}
return google[a][u] + "/?file=" + this.b + "&v=" + a + google[a].additionalparams + c
};
v[y].t = function (a) {
var b = h;
a && (b = a.packages);
var c = h;
if (b)
if ("string" == typeof b) c = [a.packages];
else if (b[x]) {
c = [];
for (a = 0; a < b[x]; a++) "string" == typeof b[a] && c[p](b[a][q](/^\s*|\s*$/, "")[d]())
}
c || (c = ["default"]);
b = [];
for (a = 0; a < c[x]; a++) this.n[":" + c[a]] || b[p](c[a]);
return b
};
n(v[y], function (a, b) {
var c = this.t(b),
e = b && b.callback != h;
if (e) var f = new x(b.callback);
for (var i = [], o = c[x] - 1; 0 <= o; o--) {
var s = c[o];
e && f.a(s);
if (this.e[":" + s]) c.splice(o, 1), e && this.f[":" + s][p](f);
else i[p](s)
}
if (c[x]) {
b && b.packages && (b.packages = c.sort()[c](","));
for (o = 0; o < i[x]; o++) s = i[o], this.f[":" + s] = [], e && this.f[":" + s][p](f);
if (!b && o[":" + this.b] != h && o[":" + this.b].versions[":" + a] != h && !google[a].additionalparams && this.j) {
c = o[":" + this.b];
google[this.b] = google[this.b] || {};
for (var s in c.properties) s && ":" ==
s[r](0) && (google[this.b][s[b](1)] = c.properties[s]);
google[a].d("script", google[a][u] + c.path + c.js, e);
c.css && google[a].d("css", google[a][u] + c.path + c.css, e)
} else(!b || !b.autoloaded) && google[a].d("script", this.g(a, b), e);
this.j && (this.j = j, this.c = (new date)[w](), 1 != this.c % 100 && (this.c = -1));
for (o = 0; o < i[x]; o++) s = i[o], this.e[":" + s] = g
}
});
v[y].l = function (a) {
-1 != this.c && (ca("al_" + this.b, "jl." + ((new date)[w]() - this.c), g), this.c = -1);
this.o = this.o.concat(a.components);
google[a][this.b] || (google[a][this.b] = {});
google[a][this.b].packages = this.o.slice(0);
for (var b = 0; b < a.components[x]; b++) {
this.n[":" + a.components[b]] = g;
this.e[":" + a.components[b]] = j;
var c = this.f[":" + a.components[b]];
if (c) {
for (var e = 0; e < c[x]; e++) c[e].b(a.components[b]);
delete this.f[":" + a.components[b]]
}
}
};
v[y].m = function (a, b) {
return 0 == this.t(b)[x]
};
v[y].s = function () {
return g
};
function x(a) {
this.d = a;
this.q = {};
this.r = 0
}
x[y].a = function (a) {
this.r++;
this.q[":" + a] = g
};
x[y].b = function (a) {
this.q[":" + a] && (this.q[":" + a] = j, this.r--, 0 == this.r && l[z](this.d, 0))
};
function w(a, b, c) {
this.name = a;
this.c = b;
this.p = c;
this.u = this.h = j;
this.k = [];
google[a].v[this[v]] = h(this.l, this)
}
g(w, v);
n(w[y], function (a, b) {
var c = b && b.callback != h;
c ? (this.k[p](b.callback), b.callback = "google.loader.callbacks." + this[v]) : this.h = g;
(!b || !b.autoloaded) && google[a].d("script", this.g(a, b), c)
});
w[y].m = function (a, b) {
return b && b.callback != h ? this.u : this.h
};
w[y].l = function () {
this.u = g;
for (var a = 0; a < this.k[x]; a++) l[z](this.k[a], 0);
this.k = []
};
var y = function (a, b) {
return a.string ? k(a.string) + "=" + k(b) : a.regex ? b[q](/(^.*$)/, a.regex) : ""
};
w[y].g = function (a, b) {
return this.f(this.w(a), a, b)
};
w[y].f = function (a, b, c) {
var e = "";
a.key && (e += "&" + y(a.key, google[a].apikey));
a.version && (e += "&" + y(a.version, b));
b = google[a].secure && a.ssl ? a.ssl : a.uri;
if (c != h)
for (var f in c) a.params[f] ? e += "&" + y(a.params[f], c[f]) : "other_params" == f ? e += "&" + c[f] : "base_domain" == f && (b = "http://" + c[f] + a.uri[b](a.uri[t]("/", 7)));
google[this[v]] = {}; - 1 == b[t]("?") && e && (e = "?" + e[b](1));
return b + e
};
w[y].s = function (a) {
return this.w(a).deferred
};
w[y].w = function (a) {
if (this.p)
for (var b = 0; b < this.p[x]; ++b) {
var c = this.p[b];
if (regexp(c.pattern).test(a)) return c
}
return this.c
};
function u(a, b) {
this.b = a;
this.i = b;
this.h = j
}
g(u, v);
n(u[y], function (a, b) {
this.h = g;
google[a].d("script", this.g(a, b), j)
});
u[y].m = function () {
return this.h
};
u[y].l = function () {};
u[y].g = function (a, b) {
if (!this.i.versions[":" + a]) {
if (this.i.aliases) {
var c = this.i.aliases[":" + a];
c && (a = c)
}
if (!this.i.versions[":" + a]) throw i("module: '" + this.b + "' with version '" + a + "' not found!");
}
return google[a].googleapisbase + "/libs/" + this.b + "/" + a + "/" + this.i.versions[":" + a][b && b.uncompressed ? "uncompressed" : "compressed"]
};
u[y].s = function () {
return j
};
var da = j,
z = [],
ea = (new date)[w](),
ga = function () {
da || (q(l, "unload", fa), da = g)
},
ha = function (a, b) {
ga();
if (!google[a].secure && (!google[a].options || google[a].options.csi === j)) {
for (var c = 0; c < a[x]; c++) a[c] = k(a[c][d]()[q](/[^a-z0-9_.]+/g, "_"));
for (c = 0; c < b[x]; c++) b[c] = k(b[c][d]()[q](/[^a-z0-9_.]+/g, "_"));
l[z](h($, h, "//gg.google.com/csi?s=uds&v=2&action=" + a[c](",") + "&it=" + b[c](",")), 1e4)
}
},
ca = function (a, b, c) {
c ? ha([a], [b]) : (ga(), z[p]("r" + z[x] + "=" + k(a + (b ? "|" + b : ""))), l[z](fa, 5 < z[x] ? 0 : 15e3))
},
fa = function () {
if (z[x]) {
var a =
google[a][u];
0 == a[t]("http:") && (a = a[q](/^http:/, "https:"));
$(a + "/stats?" + z[c]("&") + "&nc=" + (new date)[w]() + "_" + ((new date)[w]() - ea));
z.length = 0
}
},
$ = function (a) {
var b = new image,
c = $.g++;
$.z[c] = b;
b.onload = b.onerror = function () {
delete $.z[c]
};
b.src = a;
b = h
};
$.z = {};
$.g = 0;
j("google.loader.recordcsistat", ha);
j("google.loader.recordstat", ca);
j("google.loader.createimageforlogging", $);
})();
google.loader.rm({
"specs": ["feeds", "spreadsheets", "gdata", "visualization", {
"name": "sharing",
"basespec": {
"uri": "http://www.google.com/s2/sharing/js",
"ssl": null,
"key": {
"string": "key"
},
"version": {
"string": "v"
},
"deferred": false,
"params": {
"language": {
"string": "hl"
}
}
}
}, "search", "orkut", "ads", "elements", {
"name": "books",
"basespec": {
"uri": "http://books.google.com/books/api.js",
"ssl": "https://encrypted.google.com/books/api.js",
"key": {
"string": "key"
},
"version": {
"string": "v"
},
"deferred": true,
"params": {
"callback": {
"string": "callback"
},
"language": {
"string": "hl"
}
}
}
}, {
"name": "friendconnect",
"basespec": {
"uri": "http://www.google.com/friendconnect/script/friendconnect.js",
"ssl": null,
"key": {
"string": "key"
},
"version": {
"string": "v"
},
"deferred": false,
"params": {}
}
}, "identitytoolkit", "ima", {
"name": "maps",
"basespec": {
"uri": "http://maps.google.com/maps?file\u003dgoogleapi",
"ssl": "https://maps-api-ssl.google.com/maps?file\u003dgoogleapi",
"key": {
"string": "key"
},
"version": {
"string": "v"
},
"deferred": true,
"params": {
"callback": {
"regex": "callback\u003d$1\u0026async\u003d2"
},
"language": {
"string": "hl"
}
}
},
"customspecs": [{
"uri": "http://maps.googleapis.com/maps/api/js",
"ssl": "https://maps.googleapis.com/maps/api/js",
"version": {
"string": "v"
},
"deferred": true,
"params": {
"callback": {
"string": "callback"
},
"language": {
"string": "hl"
}
},
"pattern": "^(3|3..*)$"
}]
}, "payments", "wave", "annotations_v2", "earth", "language", {
"name": "annotations",
"basespec": {
"uri": "http://www.google.com/reviews/scripts/annotations_bootstrap.js",
"ssl": null,
"key": {
"string": "key"
},
"version": {
"string": "v"
},
"deferred": true,
"params": {
"callback": {
"string": "callback"
},
"language": {
"string": "hl"
},
"country": {
"string": "gl"
}
}
}
}, "picker"]
});
google.loader.rfm({
":search": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/search/1.0/523aed65e4aba49d1d640dadc8a0c37c/",
"js": "default+zh_cn.i.js",
"css": "default+zh_cn.css",
"properties": {
":jshash": "523aed65e4aba49d1d640dadc8a0c37c",
":nooldnames": false,
":version": "1.0"
}
},
":language": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/language/1.0/895197a38226304ef49a03d324d6ca19/",
"js": "default+zh_cn.i.js",
"properties": {
":jshash": "895197a38226304ef49a03d324d6ca19",
":version": "1.0"
}
},
":feeds": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/feeds/1.0/77f89919ef841f93359ce886504e4e3f/",
"js": "default+zh_cn.i.js",
"css": "default+zh_cn.css",
"properties": {
":jshash": "77f89919ef841f93359ce886504e4e3f",
":version": "1.0"
}
},
":spreadsheets": {
"versions": {
":0": "1",
":0.4": "1"
},
"path": "/api/spreadsheets/0.4/87ff7219e9f8a8164006cbf28d5e911a/",
"js": "default.i.js",
"properties": {
":jshash": "87ff7219e9f8a8164006cbf28d5e911a",
":version": "0.4"
}
},
":ima": {
"versions": {
":3": "1",
":3.0": "1"
},
"path": "/api/ima/3.0/28a914332232c9a8ac0ae8da68b1006e/",
"js": "default.i.js",
"properties": {
":jshash": "28a914332232c9a8ac0ae8da68b1006e",
":version": "3.0"
}
},
":wave": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/wave/1.0/3b6f7573ff78da6602dda5e09c9025bf/",
"js": "default.i.js",
"properties": {
":jshash": "3b6f7573ff78da6602dda5e09c9025bf",
":version": "1.0"
}
},
":annotations": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/annotations/1.0/b367e3f4388025885f0fd77f722f567e/",
"js": "default+zh_cn.i.js",
"properties": {
":jshash": "b367e3f4388025885f0fd77f722f567e",
":version": "1.0"
}
},
":earth": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/earth/1.0/109c7b2bae7fe6cc34ea875176165d81/",
"js": "default.i.js",
"properties": {
":jshash": "109c7b2bae7fe6cc34ea875176165d81",
":version": "1.0"
}
},
":picker": {
"versions": {
":1": "1",
":1.0": "1"
},
"path": "/api/picker/1.0/9f12d82446e96eb628659bd51eee66cf/",
"js": "default.i.js",
"css": "default.css",
"properties": {
":jshash": "9f12d82446e96eb628659bd51eee66cf",
":version": "1.0"
}
}
});
google.loader.rpl({
":scriptaculous": {
"versions": {
":1.8.3": {
"uncompressed": "scriptaculous.js",
"compressed": "scriptaculous.js"
},
":1.9.0": {
"uncompressed": "scriptaculous.js",
"compressed": "scriptaculous.js"
},
":1.8.2": {
"uncompressed": "scriptaculous.js",
"compressed": "scriptaculous.js"
},
":1.8.1": {
"uncompressed": "scriptaculous.js",
"compressed": "scriptaculous.js"
}
},
"aliases": {
":1.8": "1.8.3",
":1": "1.9.0",
":1.9": "1.9.0"
}
},
":yui": {
"versions": {
":2.6.0": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":2.9.0": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":2.7.0": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":2.8.0r4": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":2.8.2r1": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":2.8.1": {
"uncompressed": "build/yuiloader/yuiloader.js",
"compressed": "build/yuiloader/yuiloader-min.js"
},
":3.3.0": {
"uncompressed": "build/yui/yui.js",
"compressed": "build/yui/yui-min.js"
}
},
"aliases": {
":3": "3.3.0",
":2": "2.9.0",
":2.7": "2.7.0",
":2.8.2": "2.8.2r1",
":2.6": "2.6.0",
":2.9": "2.9.0",
":2.8": "2.8.2r1",
":2.8.0": "2.8.0r4",
":3.3": "3.3.0"
}
},
":swfobject": {
"versions": {
":2.1": {
"uncompressed": "swfobject_src.js",
"compressed": "swfobject.js"
},
":2.2": {
"uncompressed": "swfobject_src.js",
"compressed": "swfobject.js"
}
},
"aliases": {
":2": "2.2"
}
},
":webfont": {
"versions": {
":1.0.12": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.13": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.14": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.15": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.10": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.11": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.2": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.1": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.0": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.19": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.6": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.18": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.5": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.17": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.4": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.16": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.3": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.9": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.21": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.22": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.25": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.26": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.23": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
},
":1.0.24": {
"uncompressed": "webfont_debug.js",
"compressed": "webfont.js"
}
},
"aliases": {
":1": "1.0.26",
":1.0": "1.0.26"
}
},
":ext-core": {
"versions": {
":3.1.0": {
"uncompressed": "ext-core-debug.js",
"compressed": "ext-core.js"
},
":3.0.0": {
"uncompressed": "ext-core-debug.js",
"compressed": "ext-core.js"
}
},
"aliases": {
":3": "3.1.0",
":3.0": "3.0.0",
":3.1": "3.1.0"
}
},
":mootools": {
"versions": {
":1.3.1": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.1.1": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.3.0": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.3.2": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.1.2": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.2.3": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.2.4": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.2.1": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.2.2": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.2.5": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.4.0": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.4.1": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
},
":1.4.2": {
"uncompressed": "mootools.js",
"compressed": "mootools-yui-compressed.js"
}
},
"aliases": {
":1": "1.1.2",
":1.11": "1.1.1",
":1.4": "1.4.2",
":1.3": "1.3.2",
":1.2": "1.2.5",
":1.1": "1.1.2"
}
},
":jqueryui": {
"versions": {
":1.8.0": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.2": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.1": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.15": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.14": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.13": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.12": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.11": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.10": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.17": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.16": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.6.0": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.9": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.7": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.8": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.7.2": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.5": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.7.3": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.6": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.7.0": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.7.1": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.8.4": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.5.3": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
},
":1.5.2": {
"uncompressed": "jquery-ui.js",
"compressed": "jquery-ui.min.js"
}
},
"aliases": {
":1.8": "1.8.17",
":1.7": "1.7.3",
":1.6": "1.6.0",
":1": "1.8.17",
":1.5": "1.5.3",
":1.8.3": "1.8.4"
}
},
":chrome-frame": {
"versions": {
":1.0.2": {
"uncompressed": "cfinstall.js",
"compressed": "cfinstall.min.js"
},
":1.0.1": {
"uncompressed": "cfinstall.js",
"compressed": "cfinstall.min.js"
},
":1.0.0": {
"uncompressed": "cfinstall.js",
"compressed": "cfinstall.min.js"
}
},
"aliases": {
":1": "1.0.2",
":1.0": "1.0.2"
}
},
":prototype": {
"versions": {
":1.7.0.0": {
"uncompressed": "prototype.js",
"compressed": "prototype.js"
},
":1.6.0.2": {
"uncompressed": "prototype.js",
"compressed": "prototype.js"
},
":1.6.1.0": {
"uncompressed": "prototype.js",
"compressed": "prototype.js"
},
":1.6.0.3": {
"uncompressed": "prototype.js",
"compressed": "prototype.js"
}
},
"aliases": {
":1.7": "1.7.0.0",
":1.6.1": "1.6.1.0",
":1": "1.7.0.0",
":1.6": "1.6.1.0",
":1.7.0": "1.7.0.0",
":1.6.0": "1.6.0.3"
}
},
":dojo": {
"versions": {
":1.3.1": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.3.0": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.6.1": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.1.1": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.3.2": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.6.0": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.2.3": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.7.2": {
"uncompressed": "dojo/dojo.js.uncompressed.js",
"compressed": "dojo/dojo.js"
},
":1.7.0": {
"uncompressed": "dojo/dojo.js.uncompressed.js",
"compressed": "dojo/dojo.js"
},
":1.7.1": {
"uncompressed": "dojo/dojo.js.uncompressed.js",
"compressed": "dojo/dojo.js"
},
":1.4.3": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.5.1": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.5.0": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.2.0": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.4.0": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
},
":1.4.1": {
"uncompressed": "dojo/dojo.xd.js.uncompressed.js",
"compressed": "dojo/dojo.xd.js"
}
},
"aliases": {
":1.7": "1.7.2",
":1": "1.6.1",
":1.6": "1.6.1",
":1.5": "1.5.1",
":1.4": "1.4.3",
":1.3": "1.3.2",
":1.2": "1.2.3",
":1.1": "1.1.1"
}
},
":jquery": {
"versions": {
":1.6.2": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.3.1": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.6.1": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.3.0": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.6.4": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.6.3": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.3.2": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.6.0": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.2.3": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.7.0": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.7.1": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.2.6": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.4.3": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.4.4": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.5.1": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.5.0": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.4.0": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.5.2": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.4.1": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
},
":1.4.2": {
"uncompressed": "jquery.js",
"compressed": "jquery.min.js"
}
},
"aliases": {
":1.7": "1.7.1",
":1.6": "1.6.4",
":1": "1.7.1",
":1.5": "1.5.2",
":1.4": "1.4.4",
":1.3": "1.3.2",
":1.2": "1.2.6"
}
}
});
}
(function () {
if (!("google" in window)) {
window.google = {}
}
if (!("earth" in window.google)) {
window.google.earth = {}
};
if (!("google" in window)) {
window.google = {}
}
if (!("idlglue" in window.google)) {
window.google.idlglue = {}
}
window.google.idlglue.browser_firefox = "ff";
window.google.idlglue.browser_ie = "ie";
window.google.idlglue.browser_mozilla = "moz";
window.google.idlglue.browser_opera = "opera";
window.google.idlglue.browser_netscape = "netscape";
window.google.idlglue.browser_chrome = "chrome";
window.google.idlglue.browser_safari = "safari";
window.google.idlglue.browser_google_earth = "google earth";
window.google.idlglue.supportsnpapi =
function (a) {
var b = window.google.idlglue;
return a == b.browser_firefox || a == b.browser_mozilla || a == b.browser_netscape || a == b.browser_chrome || a == b.browser_opera || a == b.browser_safari || a == b.browser_google_earth
};
window.google.idlglue.platform_mac = "mac";
window.google.idlglue.platform_linux = "linux";
window.google.idlglue.platform_windows = "windows";
window.google.idlglue.plugin_main_clsid = "f9152aec-3462-4632-8087-eee3c3cdda24";
window.google.idlglue.plugin_main_mimetype = "application/geplugin";
window.google.idlglue.findavailableid =
function (a) {
var b = null;
for (var d = 0; d < 100; d++) {
var e = a + d;
if (!document.getelementbyid(e)) {
b = e
}
}
return b
};
window.google.idlglue.getplatform = function () {
var a = navigator.useragent;
if (a.indexof("windows") >= 0) {
return window.google.idlglue.platform_windows
}
if (a.indexof("macintosh") >= 0) {
return window.google.idlglue.platform_mac
}
if (a.indexof("linux") >= 0) {
return window.google.idlglue.platform_linux
}
return null
};
window.google.idlglue.getbrowser = function () {
var a = navigator.appname,
b = navigator.useragent,
d = window.google.idlglue,
e = d.getplatform();
if (b.indexof("google earth") >= 0) {
return d.browser_google_earth
} else if (b.indexof("opera") >= 0) {
return d.browser_opera
} else if (b.indexof("firefox") >= 0 || b.indexof("minefield") >= 0) {
return d.browser_firefox
} else if (b.indexof("chrome") >= 0) {
return d.browser_chrome
} else if (b.indexof("safari") >= 0) {
return d.browser_safari
} else if (a.indexof("internet explorer") >= 0) {
return d.browser_ie
} else if (a.indexof("mozilla") >= 0) {
return d.browser_mozilla
} else if (a.indexof("netscape") >= 0) {
return d.browser_netscape
}
return null
};
window.google.idlglue.getiemajorversion = function () {
var a = navigator.useragent,
b = a.indexof("msie ");
if (b == -1) {
return 0
} else {
return parseint(a.substring(b + 5, a.indexof(";", b)), 10)
}
};
window.google.idlglue.issupportedplatform = function (a) {
var b = window.google.idlglue;
return a == b.platform_windows || a == b.platform_mac
};
window.google.idlglue.isdeprecatedplatform = function () {
var a = navigator.useragent,
b = a.indexof("ppc mac") >= 0,
d = false,
e = /mac os x 10[_.]4[^0-9]/,
f = e.exec(a),
d = f && f.length > 0;
return b || d
};
window.google.idlglue.issupportedbrowser =
function (a, b) {
var d = window.google.idlglue;
if (a == d.platform_windows) {
return b == d.browser_firefox || b == d.browser_ie || b == d.browser_chrome || b == d.browser_mozilla || b == d.browser_netscape || b == d.browser_opera || b == d.browser_google_earth
} else if (a == d.platform_mac) {
return b == d.browser_firefox || b == d.browser_safari || b == d.browser_chrome || b == d.browser_opera || b == d.browser_google_earth
} else if (a == d.platform_linux) {
return b == d.browser_firefox || b == d.browser_mozilla
}
return false
};
window.google.idlglue.issupported = function () {
var a =
document.location.hash;
if (a.indexof("geplugin_browserok") != -1) return true;
var b = window.google.idlglue,
d = b.getplatform(),
e = b.getbrowser();
if (b.issupportedplatform(d) && b.issupportedbrowser(d, e)) {
return true
}
return false
};
window.google.idlglue.logcsi = function (a, b, d, e) {
var f = window.location.protocol == "https:";
window.google.idlglue.logcsi2(a, b, f, d, e)
};
window.google.idlglue.logcsi2 = function (a, b, d, e, f) {
if (e.length) {
var c = "";
for (var i = 0; i < e.length; i++) {
var g = e[i];
if (i > 0) {
c += ","
}
c += g[0] + "." + g[1]
}
var l = "http://csi.gstatic.com/csi";
if (d) {
l = "https://www.google.com/csi"
}
var h = l + "?v=2&s=" + a + "&rls=" + b + "&it=" + c;
if (f) {
h += "&" + f
}
window.google.idlglue.createimageforlogging(h)
}
};
window.google.idlglue.createimageforlogging = function (a) {
/*
var b = new image,
d = window.google.idlglue.createimageforlogging.n++;
window.google.idlglue.createimageforlogging.g[d] = b;
b.onload = (b.onerror = function () {
delete window.google.idlglue.createimageforlogging.g[d]
});
b.src = a;
b = null
*/
};
window.google.idlglue.createimageforlogging.g = {};
window.google.idlglue.createimageforlogging.n =
0;
window.google.idlglue.showerror = function (a, b, d) {
var e = window.google.idlglue;
if (!a.plugindiv) {
return
}
a.plugindiv.style.left = "" + -screen.width * 2 + "px";
a.plugindiv.style.top = "" + -screen.height * 2 + "px";
a.messagediv.style.display = "";
var f = "";
if (d) {
f = "&detail=" + encodeuricomponent(d)
}
a.messagediv.innerhtml = '<iframe src="' + a.errorurl + "#error=" + encodeuricomponent(b) + f + '" width="100%" height="100%" frameborder=0></iframe>';
e.doerrorcleanup(a)
};
window.google.idlglue.doerrorcleanup = function (a) {
var b = a.errorcleanupcallbacks;
if (b) {
for (var d = 0; d < b.length; d++) {
b[d]()
}
a.errorcleanupcallbacks = null
}
if (a.plugindiv.parentnode == a.positioningdiv) {
a.positioningdiv.removechild(a.plugindiv)
}
a.iface = null;
a.div = null;
a.plugindiv = null
};
window.google.idlglue.createpluginasinnerhtml = function (a, b, d) {
var e = window.google.idlglue;
if (window.google.idlglue.supportsnpapi(a)) {
b.innerhtml = '<embed type="' + e.plugin_main_mimetype + '" style="margin:0px; padding:0px; width:100%; height:100%;"></embed>';
return true
} else if (a == e.browser_ie) {
b.innerhtml =
'<object id="' + d + '" classid="clsid:' + e.plugin_main_clsid + '" style="margin:0px; padding:0px; width:100%; height:100%;"></object>';
return true
}
b.innerhtml = "<div></div>";
return false
};
window.google.idlglue.adderrorcleanupcallback = function (a, b) {
if (!a.errorcleanupcallbacks) {
a.errorcleanupcallbacks = []
}
a.errorcleanupcallbacks.push(b)
};
window.google.idlglue.create = function (a, b, d, e) {
var f = window.google.idlglue;
e = e || {};
var c = f.getbrowser(),
i = f.getplatform(),
g = f.issupported(),
l = (new date).gettime(),
h = document.createelement("div");
h.style.position = "relative";
h.style.width = "100%";
h.style.height = "100%";
h.style.overflow = "hidden";
a.appendchild(h);
if (i == f.platform_mac) {
var j = document.createelement("div");
j.style.position = "absolute";
j.style.width = "100%";
j.style.height = "100%";
j.style.background = "#fff";
h.appendchild(j)
}
//changed by yaodong
//var xx = document.createelement("div");
//yy = xx.style;
//yy.position = "relative";
//yy.width = "50px";
//yy.height = "50px";
//yy.background = "url(" + window.google.earth.l + ") no-repeat";
//yy.marginleft = "auto";
//yy.marginright = "auto";
//yy.margintop = (document.body.clientheight - 50)/2;
//var m = document.createelement("div");
//m.appendchild(xx);
//m.classname = "bg";
//h.appendchild(m);
//end change
var m = document.createelement("div"),
n = m.style;
n.position = "relative";
n.width = "100%";
n.height = "100%";
//n.background = "#e5e3df url(" + window.google.earth.l + ") no-repeat scroll 50% 50%";
n.background = "#ffffff url(" + window.google.earth.l + ") no-repeat scroll 50% 50%";
h.appendchild(m);
var o = document.createelement("div");
n = o.style;
n.position = "relative";
n.left = "" + -screen.width * 2 + "px";
n.top = "" + -screen.height * 2 + "px";
n.width = "100%";
n.height = "100%";
h.appendchild(o);
var k = {};
k.div = o;
k.plugindiv = o;
k.divinner = o;
k.topdiv = a;
k.positioningdiv = h;
k.messagediv = m;
k.platform = i;
k.browser = c;
k.errorurl = d;
k.startloadingtime = l;
var p = f.findavailableid("__idlglue_plugin__");
if (!p) {
f.showerror(k, "err_no_available_id", "");
return null
}
k.pluginid = p;
o.id = "_idlglue_plugindiv_" + p;
//var ld=document.createelement("div");
//ld.classname="ld";
//o.appendchild(ld);
if (g && !f.isinstalled() && !f.isdeprecatedplatform()) {
if (e.skipdownloadbutton) {
if (e.autodownload ==
undefined || e.autodownload) {
f.showerror(k, "installing", "")
} else {
f.showerror(k, "view_installing", "")
}
} else {
f.showerror(k, "err_not_installed", "")
}
b(null);
return
}
if (!f.isinstalled() && f.isdeprecatedplatform()) {
f.showerror(k, "err_unsupported_platform", "");
b(null);
return
}
if (!g && (!i || !f.issupportedplatform(i))) {
f.showerror(k, "err_unsupported_platform", "");
b(null);
return
}
if (!g || !f.createpluginasinnerhtml(c, o, p)) {
f.showerror(k, "err_unsupported_browser", "");
b(null);
return
}
var s = function (q, v) {
window.settimeout(function () {
q.iface =
v.firstchild;
if (!("getself" in q.iface)) {
f.showerror(q, "err_create_plugin", "");
b(null)
} else {
b(q)
}
}, 1)
};
s(k, o)
};
window.google.idlglue.getplugincontainernode = function (a) {
if (!a || !("getdiv_" in a)) {
return null
}
var b = a.getdiv_();
return b.parentnode.parentnode
};
window.google.idlglue.isinstalled = function () {
try {
var a = window.google.idlglue,
b = a.getbrowser();
if (window.google.idlglue.supportsnpapi(b)) {
var d = navigator.mimetypes[a.plugin_main_mimetype];
if (d && d.enabledplugin) {
return true
}
} else if (b == a.browser_ie) {
var e =
document.createelement("div"),
f = a.findavailableid("isinstalled_test");
if (a.createpluginasinnerhtml(b, e, f)) {
return e.firstchild.getself() != null
}
}
} catch (c) {}
return false
};
window.google.earth.errorcode = {
err_ok: "err_ok",
err_destroyed: "err_destroyed",
err_create_plugin: "err_create_plugin",
err_invalid_div: "err_invalid_div",
err_no_available_id: "err_no_available_id",
err_unsupported_browser: "err_unsupported_browser",
err_unsupported_platform: "err_unsupported_platform",
err_max_earth_processes: "err_max_earth_processes",
err_shutoff: "err_shutoff",
err_not_installed: "err_not_installed",
err_init: "err_init",
err_version: "err_version",
err_api_key: "err_api_key",
err_earth_not_ready: "err_earth_not_ready",
err_bridge: "err_bridge",
err_create_earth: "err_create_earth",
err_create_connect_mutex: "err_create_connect_mutex",
err_earth_connect_timeout: "err_earth_connect_timeout",
err_bridge_other_side_problem: "err_bridge_other_side_problem",
err_bridge_timeout: "err_bridge_timeout",
err_plugin_not_ready: "err_plugin_not_ready",
err_bad_url: "err_bad_url",
err_database_login_failure: "err_database_login_failure",
err_invalid_language: "err_invalid_language"
};
window.google.earth.errorcodetostring = {
0: "err_ok",
1: "err_destroyed",
100: "err_create_plugin",
101: "err_invalid_div",
102: "err_no_available_id",
103: "err_unsupported_browser",
104: "err_unsupported_platform",
105: "err_max_earth_processes",
106: "err_shutoff",
107: "err_not_installed",
200: "err_init",
201: "err_version",
202: "err_api_key",
203: "err_earth_not_ready",
300: "err_bridge",
301: "err_create_earth",
302: "err_create_connect_mutex",
303: "err_earth_connect_timeout",
304: "err_bridge_other_side_problem",
305: "err_bridge_timeout",
400: "err_plugin_not_ready",
401: "err_bad_url",
402: "err_database_login_failure",
403: "err_invalid_language"
};
(function () {
function a(c, i, g, l) {
var h = this;
h.left = c != undefined ? c : -1;
h.top = i != undefined ? i : -1;
h.width = g != undefined ? g : -1;
h.height = l != undefined ? l : -1
}
function b(c) {
var i = c.offsetwidth,
g = c.offsetheight;
if (c.getboundingclientrect) {
var l = c.getboundingclientrect(),
h = l.left,
j = l.top,
m = c.ownerdocument;
h += math.max(m.documentelement.scrollleft, m.body.scrollleft);
j += math.max(m.documentelement.scrolltop, m.body.scrolltop);
h += -m.documentelement.clientleft;
j += -m.documentelement.clienttop;
return new a(h, j, i, g)
}
var h =
0,
j = 0;
while (c) {
h += c.offsetleft;
j += c.offsettop;
try {
c = c.offsetparent
} catch (n) {
c = c.parentnode
}
}
return new a(h, j, i, g)
}
function d(c) {
var i = false;
while (c) {
if (c == document) {
return true
}
var g;
if ("getcomputedstyle" in window) {
g = window.getcomputedstyle(c, "")
} else if ("currentstyle" in c) {
g = c.currentstyle
} else {
g = c.style
} if (g.display == "none") {
return false
}
if (!i) {
if (g.visibility == "hidden") {
return false
} else if (g.visibility == "visible") {
i = true
}
}
c = c.parentnode
}
return true
}
f.addition = "addition";
f.pre_removal = "pre_removal";
f.removal = "removal";
f.bounds = "bounds";
f.visibility = "visibility";
f.get_rect_in_pixels = "get_rect_in_pixels";
function e() {
var c = this;
c.b = {}
}
e.prototype.c = false;
e.prototype._dispatchcallback = function (c, i) {
var g = this;
if (g.c || !g._hascallback(c)) {
return null
}
g.c = true;
try {
var l = g.b[c](c, i)
} catch (h) {}
g.c = false;
return l
};
e.prototype._setcallback = function (c, i) {
if (i) {
this.b[c] = i
} else {
delete this.b[c]
}
};
e.prototype._hascallback = function (c) {
return c in this.b && this.b[c]
};
function f(c, i) {
var g = this;
g.node = c;
g.rect =
new a;
g.visibility = d(c);
c.i = "nodeobserverid_" + g.d;
g.d++;
g.i = c.i;
if (i) {
g.callbacks = i
} else {
g.callbacks = new e
}
var l = 250;
g.j = setinterval(function () {
g.k()
}, l)
}
f.prototype.d = 0;
f.prototype.k = function () {
var c = this,
i = false,
g = c.node.parentnode;
while (g) {
if (g == document) {
i = true;
break
}
g = g.parentnode
}
if (!i) {
c.callbacks._dispatchcallback(f.pre_removal, c);
c.callbacks._dispatchcallback(f.removal, c);
c.destroy();
return
}
var l = false,
h = false;
if (c.callbacks._hascallback(f.bounds)) {
var j = c.rect,
m;
if (c.callbacks._hascallback(f.get_rect_in_pixels)) {
m =
c.callbacks._dispatchcallback(f.get_rect_in_pixels, c)
} else {
m = b(c.node)
}
l = j.left != m.left || j.top != m.top || j.width != m.width || j.height != m.height;
c.rect = m;
if (l) {
c.callbacks._dispatchcallback(f.bounds, c)
}
}
if (c.callbacks._hascallback(f.visibility)) {
var n = d(c.node),
h = c.visibility != n;
c.visibility = n;
if (h) {
c.callbacks._dispatchcallback(f.visibility, c)
}
}
};
f.prototype.destroy = function () {
var c = this;
if (c.j != -1) {
clearinterval(c.j)
}
c.callbacks = {}
};
google.idlglue.nodeobserver = f;
google.idlglue.nodeobservercallbacks =
e;
google.idlglue.rect = a;
google.idlglue.getelementrect = b
})();
window.google.earth.h = "";
window.google.earth.setlanguage = function (a) {
window.google.earth.h = a
};
window.google.earth.seterrorurl = function (a) {
window.google.earth.f = a
};
window.google.earth.setissecure = function (a) {
window.google.earth.e = a
};
window.google.earth.setloadingimageurl = function (a) {
window.google.earth.l = a
};
window.google.earth.createinstance = function (a, b, d, e) {
var f = window.google.earth.errorcode,
c;
b = b || function () {};
d = d || function () {};
e = e || {};
if (typeof a == "string") {
c = document.getelementbyid(a)
} else {
c =
a
} if (!c) {
d(f.err_invalid_div);
return
}
e.language = e.language || google.earth.h;
e.issecure = google.earth.e;
e.allowemptyclientid = true;
var i = b;
b = function (k) {
var p = k.getlayerroot().getlayerbyid(k.layer_borders);
if (p) {
google.earth.addeventlistener(p, "click", function (s) {
s.preventdefault()
})
}
i(k)
};
var g = "";
try {
if (e.language) {
g = "intl/" + e.language + "/"
}
} catch (l) {
}
var h = "http://www.google.com/";
if (window.google.earth.e) {
h = "https://www.google.com/"
}
var j = h + g + "earth/plugin/error.html";
if ("database" in e && typeof e.database ==
"string" && window.google.earth.f) {
j = window.google.earth.f
}
var m = window.google.earth.stopintrospectinstallation_(),
n = window.google.earth.m(f, b, d, m, e),
o = {
skipdownloadbutton: e.skipdownloadbutton,
autodownload: e.autodownload
};
window.google.idlglue.create(c, n, j, o)
};
window.google.earth.m = function (a, b, d, e, f) {
return function (c) {
if (c) {
var i = b;
b = function (l) {
var h = false;
google.earth.executebatch(l, function () {
h = true
});
/*
if (!h) {
var j = "success_recent_install_restart";
window.google.idlglue.showerror(c, j, "event bug");
d(j);
return
}
*/
i(l)
};
var g = c.iface.getjavascriptinitcode_();
eval(g)(c, b, d, f);
if (c.plugindiv.logstore) {
c.plugindiv.logstore.prewarmtime = e.time;
c.plugindiv.logstore.prewarmfinished = e.finished;
c.plugindiv.logstore.didprewarm = e.didprewarm
}
} else {
d(a.err_create_plugin)
}
}
};
window.google.earth.a = null;
window.google.earth.introspectinstallation_ = function () {
if (window.google.earth.a) return;
var a = document.createelement("div");
a.style.csstext = "visibility: hidden;position: absolute;width: 0px;height: 0px;";
document.body.appendchild(a);
var b = window.google.idlglue.findavailableid("introspect-installation"),
d = window.google.idlglue.getbrowser();
if (window.google.idlglue.createpluginasinnerhtml(d, a, b)) {
if ("getself" in a.firstchild) {
var e = a.firstchild.getself();
if ("introspectinstallation_" in e) {
e.introspectinstallation_();
window.google.earth.a = a
}
}
}
if (!window.google.earth.a) document.body.removechild(a)
};
if (document.getelementbyid("__maps-earth-introspect-installation__")) {
window.google.earth.introspectinstallation_()
}
window.google.earth.stopintrospectinstallation_ =
function () {
var a = {
time: -1,
finished: false
};
if (window.google.earth.a) {
var b = window.google.earth.a,
d = b.firstchild.getself();
d.stopintrospectinstallation_();
a = window.google.earth.queryintrospectinstallation_();
document.body.removechild(b);
window.google.earth.a = null
}
return a
};
window.google.earth.queryintrospectinstallation_ = function () {
var a = {
time: -1,
finished: false
};
if (window.google.earth.a) {
var b = window.google.earth.a,
d = b.firstchild.getself();
try {
a.time = d.getlogvalue_(4);
a.finished = d.getlogvalue_(3)
} catch (e) {
a.didprewarm =
true
}
}
return a
};
window.google.earth.getplugincontainernode = window.google.idlglue.getplugincontainernode;
window.google.earth.issupported = window.google.idlglue.issupported;
window.google.earth.isinstalled = window.google.idlglue.isinstalled;
window.google.earth.setissecure(window.location.protocol == "https:" || typeof window.google.loader == "object" && window.google.loader.secure);
if (window.google.earth.e) {
window.google.earth.setloadingimageurl("./images/loading.gif")
} else {
window.google.earth.setloadingimageurl("./images/loading.gif")
} if (window.google.earth.loadargs) {
var t =
window.google.earth.loadargs.split("&");
for (var r = 0; r < t.length; r++) {
if (t[r]) {
var u = t[r].split("=");
if (u.length == 2 && u[0] == "hl") {
window.google.earth.setlanguage(u[1])
}
}
}
};
google.loader.loaded({
"module": "earth",
"version": "1.0",
"components": ["default"]
});
google.loader.eval.earth = function () {
eval(arguments[0]);
};
if (google.loader.eval.scripts && google.loader.eval.scripts['earth']) {
(function () {
var scripts = google.loader.eval.scripts['earth'];
for (var i = 0; i < scripts.length; i++) {
google.loader.eval.earth(scripts[i]);
}
})();
google.loader.eval.scripts['earth'] = null;
}
})();
if (window['google'] != undefined && window['google']['loader'] != undefined) {
if (!window['google']['earth']) {
window['google']['earth'] = {};
google.earth.version = '1.0';
google.earth.jshash = '109c7b2bae7fe6cc34ea875176165d81';
google.earth.loadargs = 'file\75earth\46v\0751';
}
google.loader.writeloadtag("script", "default.i.js", false);
}
var points = [];
var bakuppoints = [];
var extracttimes = 0;
var polyparams = [];
var iconurl = 'http://www.goodygis.com/earth/icons/ylw-pushpin.png';
var markertitle = '地标';
google.load('earth', '1.x');
google.setonloadcallback(init);
function init() {
//alert('init-ge');
google.earth.createinstance('map3d', initcb, failurecb);
loadearth = true;
}
function initcb(plugininstance) {
ge = plugininstance;
ge.getwindow().setvisibility(true);
setmaplayersstatus(true, true, true, true, true, true, false, false, false, false, false, false);
gex = new gearthextensions(plugininstance);
google.earth.addeventlistener(ge.getwindow(), 'mousemove', function (event) {
var lat = event.getlatitude().tofixed(6);
var lng = event.getlongitude().tofixed(6);
var alt = ge.getglobe().getgroundaltitude(lat, lng).tofixed(3);
window.external.displaylatlngalt(lat, lng, alt);
if (mousemsgflag) {
window.external.showmsgtrackmouse();
}
});
movemaptopoint(new geo.point(clat, clng), 5300000, 6, null);
//alert("initcb-ok!");
window.external.gesuccessloadedcallback_();
}
function failurecb(errorcode) {
//alert( 'failurecb: ' + errorcode );
window.external.jsinitfailurecallback_('google earth加载失败,可能是网络原因!');
}
function setmaplayersstatus(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12) {
ge.getoptions().setstatusbarvisibility(s1);
ge.getoptions().setscalelegendvisibility(s2);
ge.getlayerroot().enablelayerbyid(ge.layer_borders, s4);
ge.getlayerroot().enablelayerbyid(ge.layer_roads, s3);
ge.getlayerroot().enablelayerbyid(ge.layer_buildings, s11);
ge.getlayerroot().enablelayerbyid(ge.layer_terrain, s6);
ge.getnavigationcontrol().setvisibility((s5 == true) ? ge.visibility_show : ge.visibility_hide);
ge.getsun().setvisibility(s7);
ge.getoptions().setatmospherevisibility(s8);
ge.getoptions().setoverviewmapvisibility(s9);
ge.getoptions().setgridvisibility(s10);
ge.gettime().sethistoricalimageryenabled(s12);
}
function switchballoon(flag) {
ge.setballoon(null);
}
function getuniqueid() {
return "oid" + (new date()).gettime() + parseint(math.random() * 100000);
}
function getobjectbyid(id) {
var foundobject = null;
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('getid' in this && this.getid() == id) {
foundobject = this;
return false;
}
}
});
return foundobject;
}
function pad2(s) {
return ((s.length < 2) ? '0' : '') + s;
}
function mergecoloropacity(color, opacity) {
color = color ? gex.util.parsecolor(color) : 'ffffffff';
if (!geo.util.isundefined(opacity)) {
color = pad2(math.floor(255 * opacity).tostring(16)) + color.substring(2);
}
return color;
}
function(a)
{
a='+a+';
}
function drawpoint2(id, point, name, description) {
pointstyle9.icon.href=licon;
gex.dom.addplacemark({
id: id,
name: name,
point: point,
description: description,
style: pointstyle9
});
}
function drawpoint(id, point, name, description) {
gex.dom.addplacemark({
id: id,
name: name,
point: point,
description: description,
style: pointstyle
});
}
function drawpointnoicon(id, point, name, description) {
gex.dom.addplacemark({
id: id,
name: name,
point: point,
description: description,
style: pointnoiconstyle
});
}
function drawpoint1(id, point, name, description) {
return gex.dom.addplacemark({
id: id,
name: name,
point: point,
description: description,
style: pointstyle1
});
}
function drawpointid(lat, lng, name, description, id) {
gex.dom.addplacemark({
id: id,
name: name,
point: [lat, lng],
description: description
});
}
function drawpathcap(id, point, name, description) {
gex.dom.addlinestringplacemark({
id: id,
// name: ' ',
name:name,
point: point,
linestring: [point],
description: description,
//style: pathstyle
style: linestyle
});
}
function addpathpoint(id, point) {
getobjectbyid(id).getgeometry().getgeometries().getchildnodes().item(1).getcoordinates().pushlatlngalt(point[0], point[1], point[2]);
}
function drawpathrearcap(id) {
var geometriesobj = getobjectbyid(id).getgeometry().getgeometries();
var coordinates = geometriesobj.getchildnodes().item(1).getcoordinates();
var pointlength = coordinates.getlength();
geometriesobj.appendchild(gex.dom.buildpoint(coordinates.get(pointlength - 1)));
}
function drawpath(id, points, name, description) {
gex.dom.addlinestringplacemark({
id: id,
name: name,
linestring: points,
description: description,
style: pathstyle
});
}
function drawrectangle(id, points, name, description) {
gex.dom.addpolygonplacemark(points, {
id: id,
name: name,
description: description,
style: {
poly: {
color: 'white',
opacity: 0,
fill: true,
outline: true
},
line: pathstyle
}
});
}
function drawpolygoncap(id, points, name, description) {
gex.dom.addpolygonplacemark(points, {
id: id,
name: name,
description: description,
style: {
poly: {
color: 'white',
opacity: 0,
fill: true,
outline: true
},
line: pathstyle
}
});
}
function addpolygonpoint(id, point) {
getobjectbyid(id).getgeometry().getouterboundary().getcoordinates().pushlatlngalt(point[0], point[1], point[2]);
}
function drawpolygon(id, points, name, description, ispolygon) {
if (ispolygon == '0') {
gex.dom.addpolygonplacemark(points, {
id: id,
name: name,
description: description,
style: {
poly: {
color: 'white',
opacity: 0.3,
fill: true,
outline: true
},
line: pathstyle
}
});
} else {
pathstyle = circlelinestyle;
gex.dom.addlinestringplacemark(points, {
id: id,
name: name,
description: description,
style: {
line: pathstyle
}
});
}
}
var downloadimgpolygonid = '';
function addpolygononearth(tlat, blat, llng, rlng) {
tlat = parsefloat(tlat);
blat = parsefloat(blat);
llng = parsefloat(llng);
rlng = parsefloat(rlng);
if (downloadimgpolygonid == '') {
downloadimgpolygonid = getuniqueid();
var points = [new geo.point(tlat, llng, 0), new geo.point(tlat, rlng, 0), new geo.point(blat, rlng, 0), new geo.point(blat, llng, 0)];
pathstyle = polygonlinestyle1;
//drawpolygon(downloadimgpolygonid, points, '多边形', '影像下载范围');
drawpolygon(downloadimgpolygonid, points, lname, ldescription);
} else {
var dipobj = getobjectbyid(downloadimgpolygonid);
var coords = dipobj.getgeometry().getouterboundary().getcoordinates();
coords.clear();
coords.pushlatlngalt(tlat, llng, 0);
coords.pushlatlngalt(tlat, rlng, 0);
coords.pushlatlngalt(blat, rlng, 0);
coords.pushlatlngalt(blat, llng, 0);
}
}
function creategeopointbylatlngalt(lat, lng, alt) {
return new geo.point(lat, lng, alt);
}
function getgeopointaltitude(point) {
return ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3);
}
function gethorizontaldistance(startpoint, endpoint) {
return startpoint.distance(endpoint);
}
function getverticaldistance(startpoint, endpoint) {
return abs(startpoint.altitude() - endpoint.altitude()).tofixed(2);
}
function getactualdistance(startpoint, endpoint) {
return sqrt(sqit(gethorizontaldistance(startpoint, endpoint)) + sqit(getverticaldistance(startpoint, endpoint))).tofixed(2);
}
function getpointlocationbydh(startpoint, endpoint, d) {
return geo.math.destination(startpoint, {
distance: parsefloat(d).div(getstarradius(lastmapmod)),
heading: startpoint.heading(endpoint)
});
}
function getpointlocationbydha(startpoint, d, angle) {
return geo.math.destination(startpoint, {
distance: parsefloat(d).div(getstarradius(lastmapmod)),
heading: angle
});
}
function getmergeimagewidth(lng1, lat1, lng2, lat2) {
return gethorizontaldistance(new geo.point(lat1, lng1), new geo.point(lat2, lng2));
}
function getmergeimageheight(lng1, lat1, lng2, lat2) {
return gethorizontaldistance(new geo.point(lat1, lng1), new geo.point(lat2, lng2));
}
function movemaptopoint(destpoint, range, speed, heading) {
if (speed == 6) {
speed = ge.speed_teleport;
}
var lookat = ge.getview().copyaslookat(ge.altitude_relative_to_ground);
lookat.setlatitude(destpoint.lat());
lookat.setlongitude(destpoint.lng());
if (heading != null) {
lookat.setheading(heading);
}
lookat.settilt(0);
lookat.setrange(range);
ge.getoptions().setflytospeed(speed);
ge.getview().setabstractview(lookat);
}
function rotatemap(angle) {
var lookat = ge.getview().copyaslookat(ge.altitude_relative_to_ground);
lookat.setheading(angle);
ge.getview().setabstractview(lookat);
}
function sleep(num) {
var tempdate = new date();
var gonemsel = 0;
while (gonemsel < num) {
gonemsel = new date() - tempdate;
}
return true;
}
function getcurrentdirectory() {
var lochref = location.href;
var locarray = lochref.split("/");
delete locarray[locarray.length - 1];
var dirtxt = locarray.join("/");
return dirtxt;
}
function createtourkml(points, duration, range) {
var time;
var kmlstring = '<?xml version="1.0" encoding="utf-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"><gx:tour><name>smooth tour points</name><gx:playlist>';
for (var i = 0; i < points.length; i++) {
if (i == 0) {
time = duration + 1;
} else {
time = duration;
}
kmlstring += '<gx:flyto><gx:duration>10</gx:duration><gx:flytomode>smooth</gx:flytomode><lookat><longitude>' + points[i].lng() + '</longitude><latitude>' + points[i].lat() + '</latitude><altitude>10</altitude><heading>0</heading><tilt>0</tilt><range>0</range><altitudemode>relativetoground</altitudemode></lookat></gx:flyto>';
}
kmlstring += '</gx:playlist></gx:tour></kml>';
return kmlstring;
}
function settourobject(kmlstring) {
var kmlobject = ge.parsekml(kmlstring);
ge.getfeatures().appendchild(kmlobject);
walkkmldom(kmlobject, function () {
if (this.gettype() == 'kmltour') {
tour = this;
return false;
}
});
if (!tour) {
alert('no tour found!');
return;
}
ge.gettourplayer().settour(tour);
}
function playtour() {
ge.gettourplayer().play();
}
function exittour() {
ge.gettourplayer().settour(null);
}
function gettrianglepoint(firstpoint, lastpoint) {
var c = gethorizontaldistance(firstpoint, lastpoint);
var angle1 = firstpoint.heading(new geo.point(firstpoint.lat(), lastpoint.lng()));
var angle2 = firstpoint.heading(lastpoint);
var angle = math.abs(angle1.sub(angle2));
var a = c.mul(math.cos(angle.mul(math.pi).div(180)));
return getpointlocationbydha(firstpoint, a, angle1);
}
function getrectanglepoints(firstpoint, d, p) {
ppoints[0] = firstpoint;
ppoints[1] = getpointlocationbydha(ppoints[0], d * p, hheading);
ppoints[2] = getpointlocationbydha(ppoints[1], 2 * d * (p - 1), vheading);
ppoints[3] = getpointlocationbydha(ppoints[0], 2 * d * (p - 1), vheading);
}
function searchlocation_e(lat, lng) {
var lookat = ge.getview().copyaslookat(ge.altitude_relative_to_ground);
lookat.setlatitude(parsefloat(lat));
lookat.setlongitude(parsefloat(lng));
lookat.setrange(10000);
ge.getoptions().setflytospeed(2);
ge.getview().setabstractview(lookat);
drawpointid(lat, lng, "目标点", "经度:" + lng + ",纬度:" + lat, getuniqueid());
}
function computepathdistance_e(obj) {
var d = 0;
var coordinates = [];
var length = 0;
try {
if ('gettype' in obj.getgeometry()) {
if (obj.getgeometry().gettype() == 'kmllinestring') {
coordinates = obj.getgeometry().getcoordinates();
length = coordinates.getlength();
if (length > 1) {
for (var i = 1; i < length; i++) {
d = parsefloat(d).add(parsefloat(gethorizontaldistance(new geo.point(coordinates.get(i - 1)), new geo.point(coordinates.get(i))).tofixed(2)));
}
}
} else if (obj.getgeometry().gettype() == 'kmlmultigeometry') {
if (obj.getgeometry().getgeometries().getchildnodes().item(1).gettype() == 'kmllinestring') {
coordinates = obj.getgeometry().getgeometries().getchildnodes().item(1).getcoordinates();
length = coordinates.getlength();
if (length > 1) {
for (var i = 1; i < length; i++) {
d = parsefloat(d).add(parsefloat(gethorizontaldistance(new geo.point(coordinates.get(i - 1)), new geo.point(coordinates.get(i))).tofixed(2)));
}
}
}
}
}
} catch (err) {
if (obj.gettype() == 'kmllinestring') {
coordinates = obj.getcoordinates();
length = coordinates.getlength();
if (length > 1) {
for (var i = 1; i < length; i++) {
d = parsefloat(d).add(parsefloat(gethorizontaldistance(new geo.point(coordinates.get(i - 1)), new geo.point(coordinates.get(i))).tofixed(2)));
}
}
} else if (obj.gettype() == 'kmlmultigeometry') {
if (obj.getgeometries().getchildnodes().item(1).gettype() == 'kmllinestring') {
coordinates = obj.getgeometries().getchildnodes().item(1).getcoordinates();
length = coordinates.getlength();
if (length > 1) {
for (var i = 1; i < length; i++) {
d = parsefloat(d).add(parsefloat(gethorizontaldistance(new geo.point(coordinates.get(i - 1)), new geo.point(coordinates.get(i))).tofixed(2)));
}
}
}
}
}
return d;
}
function getstarradius(star) {
var r = 6371000;
var rmoon = 1737400;
var rmars = 3397200;
var ratio = 1;
if (star == 'moon') {
ratio = rmoon.div(r);
} else if (star == 'mars') {
ratio = rmars.div(r);
} else {}
return ratio;
}
function computeareaandc(obj) {
var params = [0, 0];
var coords = [];
var type = '';
var flag = true;
try {
type = obj.getgeometry().gettype();
} catch (err) {
type = obj.gettype();
flag = false;
}
switch (type) {
case 'kmllinearring':
case 'kmlpolygon':
if (flag) {
coords = obj.getgeometry().getouterboundary().getcoordinates();
} else {
coords = obj.getouterboundary().getcoordinates();
}
if (coords.getlength() >= 3) {
params = getpolygonareaandc(coords);
}
break;
case 'kmlmultigeometry':
if (flag) {
var geoms = obj.getgeometry().getgeometries();
} else {
var geoms = obj.getgeometries();
}
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmlpolygon') {
coords = geoms.getchildnodes().item(j).getouterboundary().getcoordinates();
}
}
if (coords.getlength() >= 3) {
params = getpolygonareaandc(coords);
}
break;
default:
}
return params;
}
function getpolygonareaandc(geopoints) {
var params = [0, 0];
var length = geopoints.getlength();
var firstgeopoint = new geo.point(geopoints.get(0));
var lastgeopoint = new geo.point(geopoints.get(length - 1));
var geopointi = null;
var geopointii = null;
var angle1 = 0;
var angle2 = firstgeopoint.heading(lastgeopoint);
var angle = 0;
var d = 0;
var c = 0;
var x = [];
var y = [];
x.push(0);
y.push(0);
for (var i = 1; i < length; i++) {
geopointi = new geo.point(geopoints.get(i - 1));
geopointii = new geo.point(geopoints.get(i));
d = gethorizontaldistance(geopointi, geopointii);
c = gethorizontaldistance(firstgeopoint, geopointii);
params[0] = parsefloat(params[0]).add(parsefloat(d));
angle1 = firstgeopoint.heading(geopointii);
angle = angle2.sub(angle1).add(360);
x.push(math.cos(angle.mul(math.pi).div(180)).mul(c));
y.push(math.sin(angle.mul(math.pi).div(180)).mul(c));
}
params[0] = parsefloat(params[0]).add(parsefloat(gethorizontaldistance(new geo.point(geopoints.get(0)), new geo.point(geopoints.get(length - 1)))));
params[1] = getpolygonareabycoords(x, y);
return params;
}
function getpolygonareabycoords(x, y) {
var s = 0;
var n = x.length;
x[n] = x[0];
y[n] = y[0];
for (var i = 0; i < n - 1; i++) {
s = s.add(x[i].mul(y[i + 1]).sub(x[i + 1].mul(y[i])));
}
if (n > 1) {
s = s.add(x[n].mul(y[0]).sub(x[0].mul(y[n])));
}
s = math.abs(s).mul(0.5);
return s;
}
var pagestoprunflag = false;
function cancelwebbrowserrun(key) {
if (key == "stop") {
cleartallparams();
pagestoprunflag = true;
} else {
pagestoprunflag = false;
}
}
var currentwindkmlobject = null;
var currentlidarkmlobject = null;
var currentdrawkmlobject = null;
var currentgooglemapkmlobject = null;
var currentremarkkmlobject = null;
var currentbackwardtrajkmlobject = null;
var currentforwardtrajkmlobject = null;
var isappendwind = false;
var isappendlidar= false;
var isappendgooglemap = false;
var isappendremark = false;
function importkmlfilebyurl(href, iswind, movemap) {
isappendwind = iswind;
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if( isappendwind )
{
if (currentwindkmlobject)
{
ge.getfeatures().removechild(currentwindkmlobject);
}
currentwindkmlobject = ge.getfeatures().appendchild(kmlobject);
}
else
ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
if( typeof(movemap)!="undefined" && movemap==true ){
var box = gex.dom.computebounds(kmlobject);
var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
var boxheight = gethorizontaldistance(new geo.point(box.south(), box.east()), new geo.point(box.north(), box.east())).tofixed(2);
var boxwidth = gethorizontaldistance(new geo.point(box.south(), box.west()), new geo.point(box.south(), box.east())).tofixed(2);
var range = math.max(boxheight, boxwidth);
movemaptopoint(cp, range < 5000 ? 5000 : range, 0.3, null);
}
}
}
});
}
function importdrawkmlfilebyurl(href/*, movemap*/) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentdrawkmlobject)
{
ge.getfeatures().removechild(currentdrawkmlobject);
}
currentdrawkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
/*
if( typeof(movemap)!="undefined" && movemap==true ){
var box = gex.dom.computebounds(kmlobject);
var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
var boxheight = gethorizontaldistance(new geo.point(box.south(), box.east()), new geo.point(box.north(), box.east())).tofixed(2);
var boxwidth = gethorizontaldistance(new geo.point(box.south(), box.west()), new geo.point(box.south(), box.east())).tofixed(2);
var range = math.max(boxheight, boxwidth);
movemaptopoint(cp, range < 5000 ? 5000 : range, 0.3, null);
}
*/
}
}
});
}
function importgooglemapkmlfilebyurl(href) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentgooglemapkmlobject)
{
ge.getfeatures().removechild(currentgooglemapkmlobject);
}
currentgooglemapkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
//var box = gex.dom.computebounds(kmlobject);
//var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
}
}
});
}
function importremarkkmlfilebyurl(href) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentremarkkmlobject)
{
ge.getfeatures().removechild(currentremarkkmlobject);
}
currentremarkkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
//var box = gex.dom.computebounds(kmlobject);
//var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
}
}
});
}
function importbackwardtrajkmlfilebyurl(href) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentbackwardtrajkmlobject)
{
ge.getfeatures().removechild(currentbackwardtrajkmlobject);
}
currentbackwardtrajkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
//var box = gex.dom.computebounds(kmlobject);
//var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
}
}
});
}
function importforwardtrajkmlfilebyurl(href) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentforwardtrajkmlobject)
{
ge.getfeatures().removechild(currentforwardtrajkmlobject);
}
currentforwardtrajkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
//var box = gex.dom.computebounds(kmlobject);
//var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
}
}
});
}
function importlidarkmlfilebyurl(href, movemap) {
google.earth.fetchkml(ge, href,
function (kmlobject) {
if (kmlobject) {
if (currentlidarkmlobject)
{
ge.getfeatures().removechild(currentlidarkmlobject);
}
currentlidarkmlobject = ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
if( typeof(movemap)!="undefined" && movemap==true ){
var box = gex.dom.computebounds(kmlobject);
var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
var boxheight = gethorizontaldistance(new geo.point(box.south(), box.east()), new geo.point(box.north(), box.east())).tofixed(2);
var boxwidth = gethorizontaldistance(new geo.point(box.south(), box.west()), new geo.point(box.south(), box.east())).tofixed(2);
var range = math.max(boxheight, boxwidth);
movemaptopoint(cp, range < 5000 ? 5000 : range, 0.3, null);
}
}
}
});
}
//var currentwindkmlobject = null;
function importwindkmlfilebyurl(href2/*, movemap*/) {
google.earth.fetchkml(ge, href2,
function (kmlobject2) { //alert("windkmlobject:" + kmlobject2);
if (kmlobject2) {
currentwindkmlobject = ge.getfeatures().appendchild(kmlobject2);
if (kmlobject2.getabstractview()) {
ge.getview().setabstractview(kmlobject2.getabstractview());
} else {
/*
if( typeof(movemap)!="undefined" && movemap==true ){
var box = gex.dom.computebounds(kmlobject2);
var cp = new geo.point((box.north() + box.south()) / 2, (box.east() + box.west()) / 2);
//var range = math.max(getdistancebytwopoints(box.east(), box.south(), box.east(), box.north()), getdistancebytwopoints(box.east(), box.south(), box.west(), box.south()));
//movemaptopoint(cp, range < 2000 ? 2000 : range, 6, null);
var boxheight = gethorizontaldistance(new geo.point(box.south(), box.east()), new geo.point(box.north(), box.east())).tofixed(2);
var boxwidth = gethorizontaldistance(new geo.point(box.south(), box.west()), new geo.point(box.south(), box.east())).tofixed(2);
var range = math.max(boxheight, boxwidth);
movemaptopoint(cp, range < 5000 ? 5000 : range, 0.3, null);
}
*/
}
}
});
}
/*
function importlidarkmlfile_e(kmlstring) {
var flag = 0;
var kmlobject = ge.parsekml(kmlstring);
if (kmlobject) {
currentlidarkmlobject=ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
movemaptopoint(getfirstkmlobject(kmlstring), 10000, 6, null);
}
flag = 1;
}
return flag;
}
function importwindkmlfile_e(kmlstring) {
var flag = 0;
var kmlobject = ge.parsekml(kmlstring);
if (kmlobject) {
currentwindkmlobject=ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
movemaptopoint(getfirstkmlobject(kmlstring), 10000, 6, null);
}
flag = 1;
}
return flag;
}
function importdrawkmlfile_e(kmlstring) {
var flag = 0;
var kmlobject = ge.parsekml(kmlstring);
if (kmlobject) {
currentdrawkmlobject=ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
movemaptopoint(getfirstkmlobject(kmlstring), 10000, 6, null); //放大地图
}
flag = 1;
}
return flag;
}
*/
function clearwindobjects() {
try {
if (currentwindkmlobject)
{
//alert("remove current wind kml object!");
ge.getfeatures().removechild(currentwindkmlobject);
}
else
{
//alert("not found current wind kml object!");
}
} catch (err) {}
}
function clearlidarobjects() {
try {
if (currentlidarkmlobject)
{
ge.getfeatures().removechild(currentlidarkmlobject);
}
else
{
}
} catch (err) {}
}
function cleardrawobjects() {
try {
if (currentdrawkmlobject)
{
//alert("remove current draw kml object!");
ge.getfeatures().removechild(currentdrawkmlobject);
}
else
{
//alert("not found current draw kml object!");
}
} catch (err) {}
}
function cleargooglemapobjects() {
try {
if (currentgooglemapkmlobject)
{
//alert("remove current google map kml object!");
ge.getfeatures().removechild(currentgooglemapkmlobject);
}
else
{
//alert("not found current google map kml object!");
}
} catch (err) {}
}
function clearremarkobjects() {
try {
if (currentremarkkmlobject)
{
//alert("remove current remark kml object!");
ge.getfeatures().removechild(currentremarkkmlobject);
}
else
{
//alert("not found current remark kml object!");
}
} catch (err) {}
}
function clearbackwardtrajobjects() {
try {
if (currentbackwardtrajkmlobject)
{
//alert("remove current backward traj kml object!");
ge.getfeatures().removechild(currentbackwardtrajkmlobject);
}
else
{
//alert("not found current backward traj kml object!");
}
} catch (err) {}
}
function clearforwardtrajobjects() {
try {
if (currentforwardtrajkmlobject)
{
//alert("remove current forward traj kml object!");
ge.getfeatures().removechild(currentforwardtrajkmlobject);
}
else
{
//alert("not found current forward traj kml object!");
}
} catch (err) {}
}
function createnetworklink(href) {
var link = ge.createlink('');
link.sethref(href);
var networklink = ge.createnetworklink('');
networklink.set(link, true, true);
ge.getfeatures().appendchild(networklink);
}
function importkmlfile_e(kmlstring) {
//alert('importkmlfile_e '+kmlstring);
var flag = 0;
var kmlobject = ge.parsekml(kmlstring);
if (kmlobject) {
ge.getfeatures().appendchild(kmlobject);
if (kmlobject.getabstractview()) {
ge.getview().setabstractview(kmlobject.getabstractview());
} else {
movemaptopoint(getfirstkmlobject(kmlstring), 10000, 6, null);
}
flag = 1;
}
return flag;
}
function getfirstkmlobject(kmlstring) {
var xmldoc2 = new activexobject('microsoft.xmldom');
xmldoc2.async = 'false';
xmldoc2.loadxml(kmlstring);
var docroot = xmldoc2.documentelement;
var coords = docroot.selectsinglenode('//coordinates').text.trim().split(' ');
var coord = coords[0].split(',');
coords = [];
docroot = null;
xmldoc2 = null;
kmlstring = '';
return new geo.point(parsefloat(coord[1]), parsefloat(coord[0]), parsefloat(coord[2]));
}
//原来的导出kml
/* function getgekml_e() {
var output = '';
var kmlstring = '<?xml version="1.0" encoding="utf-8"?>\r\n<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/atom">\r\n<document>\r\n';
var nodes = ge.getfeatures().getchildnodes();
var nodescount = nodes.getlength();
try {
var xmldoc2 = new activexobject('microsoft.xmldom');
xmldoc2.async = 'false';
var docroot = null;
for (var i = 0; i < nodescount; i++) {
xmldoc2.loadxml(nodes.item(i).getkml());
docroot = xmldoc2.documentelement;
if (!docroot.selectsinglenode('//document')) {
kmlstring += (docroot.selectsinglenode('//placemark').xml + '\r\n').replace('xmlns="http://www.opengis.net/kml/2.2"', '');
} else {
var docnodes = docroot.selectnodes('//document/*');
var docnodescount = docnodes.length;
for (var j = 0; j < docnodescount; j++) {
kmlstring += (docnodes[j].xml + '\r\n').replace('xmlns="http://www.opengis.net/kml/2.2"', '');
}
}
}
kmlstring += '</document>\r\n</kml>';
kmlstring = formatkmlforhtml(kmlstring);
} catch (err) {
alert('error');
}
docroot = null;
xmldoc2 = null;
return kmlstring;
}
*/
//修改后,只导出绘图信息的版本
function getgekml_e() {
var output = '';
var kmlstring = '<?xml version="1.0" encoding="utf-8"?>\r\n<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/atom">\r\n<document>\r\n';
var nodes = ge.getfeatures().getchildnodes();
var nodescount = nodes.getlength();
try {
var xmldoc2 = new activexobject('microsoft.xmldom');
xmldoc2.async = 'false';
var docroot = null;
for (var i = 0; i < nodescount; i++) {
if(nodes.item(i).gettype()=='kmlplacemark')
{
xmldoc2.loadxml(nodes.item(i).getkml());
docroot = xmldoc2.documentelement;
if (!docroot.selectsinglenode('//document')) {
kmlstring += (docroot.selectsinglenode('//placemark').xml + '\r\n').replace('xmlns="http://www.opengis.net/kml/2.2"', '');
} else {
var docnodes = docroot.selectnodes('//document/*');
var docnodescount = docnodes.length;
for (var j = 0; j < docnodescount; j++) {
kmlstring += (docnodes[j].xml + '\r\n').replace('xmlns="http://www.opengis.net/kml/2.2"', '');
}
}
}
}
kmlstring += '</document>\r\n</kml>';
kmlstring = formatkmlforhtml(kmlstring);
} catch (err) {
alert('error');
}
docroot = null;
xmldoc2 = null;
return kmlstring;
}
function formatkmlforhtml(output) {
output = output.replace(/</g, '<').replace(/>/g, '>');
output = output.replace(/\t/g, ' ');
output = output.replace(/\" xmlns/g, '\"\n xmlns');
return output;
}
function returnpointjson(point) {
return '{w:"' + point.lat().tofixed(6) + '",j:"' + point.lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3) + '"},';
}
function returndlzxpointjson(point, name, type) {
return '{n:"' + name + '",w:"' + point.lat().tofixed(6) + '",j:"' + point.lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3) + '",t:"' + type + '"},';
}
function returndlzxapointjson(point) {
var json = '';
var flag = false;
var alt = ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3);
if (dlzx[4] != 'j') {
if (dlzx[3]) {
if (parsefloat(dlzx[2]) - parsefloat(alt) > 0) {
json = '{n:"z' + zxz + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"1"},';
zxz++;
flag = false;
} else {
json = '{n:"' + fzd + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"2"},';
fzd++;
flag = true;
}
} else {
json = '{n:"' + fzd + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"2"},';
fzd++;
if (parsefloat(dlzx[2]) - parsefloat(alt) > 0) {
flag = false;
} else {
flag = true;
}
}
}
dlzx = [point.lat().tofixed(6), point.lng().tofixed(6), alt, flag, ''];
return json;
}
function returndlzxbpointjson(point, name, type) {
var flag = false;
var json = '';
var alt = ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3);
if (dlzx[4] != 'j') {
if (dlzx[3]) {
if (parsefloat(dlzx[2]) - parsefloat(alt) > 0) {
json = '{n:"z' + zxz + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"1"},';
zxz++;
flag = false;
} else {
json = '{n:"' + fzd + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"2"},';
fzd++;
flag = true;
}
} else {
json = '{n:"' + fzd + '",w:"' + dlzx[0] + '",j:"' + dlzx[1] + '",a:"' + dlzx[2] + '",t:"2"},';
fzd++;
if (parsefloat(dlzx[2]) - parsefloat(alt) > 0) {
flag = false;
} else {
flag = true;
}
}
}
dlzx = [point.lat().tofixed(6), point.lng().tofixed(6), alt, flag, 'j'];
json += returndlzxpointjson(point, name, type);
return json;
}
function searchlatlngbylocation_e(a) {
if (lastmapmod != 'earth') {
window.external.showmessagecallback_('请切换到地球模式进行地名搜索!');
return false;
}
$.getjson('http://maps.googleapis.com/maps/api/geocode/json?address=' + a + '&sensor=false', function (json) {
if (json['status'] == 'ok') {
var lat = json['results'][0]['geometry']['location']['lat'];
var lng = json['results'][0]['geometry']['location']['lng'];
searchlocation_e(lat, lng);
}
});
}
lastmapmod = 'earth';
var rubbishpoints = [];
var figtype = '';
var lwidth='5';
var lcolor='red';
var lopacity='1';
var licon='';
var lname;
var ldescription;
function drawparameter(name,description,linewidth,linecolor,lineopacity,icon,icontype)
{
lname=name;
ldescription=description;
lwidth=linewidth;
lcolor=linecolor;
lopacity=lineopacity;
licon=icon;
markertitle = icontype;
}
function drawfigure_e(figuretype) {
chushihuadrawfig_e();
figtype = figuretype;
pathstyle = linestyle;
dowhat = 0;
markertitle = '地标';
}
var cpoints = [];
function drawcontrolpoints(figuretype) {
chushihuadrawfig_e();
figtype = figuretype;
dowhat = 0;
markertitle = '控制点';
}
function cleardrawcontrolpoints() {
markertitle = '地标';
cpoints = [];
}
function addeventlistenerdrawfig_e() {
try {
google.earth.removeeventlistener(ge.getglobe(), 'mousedown', clickrightmousedrawfig);
google.earth.addeventlistener(ge.getglobe(), 'mousedown', clickrightmousedrawfig);
} catch (e) {}
}
function removeeventlistenerdrawfig_e() {
if (figtype != 'point') {
chushihuadrawfig_e();
}
figtype = '';
try {
google.earth.removeeventlistener(ge.getglobe(), 'mousedown', clickrightmousedrawfig);
dowhat = 0;
} catch (e) {}
}
var dowhat = 0;
function clickobjectdo_e(key) {
dowhat = key;
chushihuadrawfig_e();
}
var objm = 0;
function selectobjecttoidentify(key, m) {
if (lastmapmod != 'earth') {
alert('请切换到谷歌地球三维模式!');
}
bakuppoints = [];
objm = m;
if (m == 1 || m == 2) {
clickobjectdo_e(key);
addeventlistenerdrawfig_e();
} else if (m == 3) {
identifyallplacemark('kmlpoint');
selectobjectinfos('地标', '点', bakuppoints.length, 0);
} else {}
}
var objpoints = [];
var objectid = '';
var cases_e = {
'word': drawpointnoiconfunc_e,
'point': drawpointfunc_e,
'line': drawlinefunc_e,
'rectangle': drawretanglefunc_e,
'polygon': drawpolygonfunc_e
};
//鼠标事件处理
var clickrightmousedrawfig = function (event) {
if (event.getbutton() == 2 && dowhat == 0) {
if (cases_e[figtype]) {
cases_e[figtype](event);
}
} else if (event.getbutton() == 0 && dowhat == 1 && event.gettarget().gettype() == 'kmlplacemark') {
removeobject(event.gettarget());
dowhat = 0;
window.external.exitdeletemode();
} else if (event.getbutton() == 0 && dowhat == 2 && event.gettarget().gettype() == 'kmlplacemark') {
editobject(event.gettarget());
} else if (event.getbutton() == 0 && dowhat == 3 && event.gettarget().gettype() == 'kmlplacemark') {
selectmeasureobject(event.gettarget());
} else if (event.getbutton() == 0 && dowhat == 0 && event.gettarget().gettype() == 'kmlplacemark') {
identifyobject(event.gettarget());
getobjectbounds(event.gettarget());
getpathidentify(event.gettarget());
}
}
function drawpointnoiconfunc_e(event) {
drawpointnoicon(getuniqueid(), [event.getlatitude(), event.getlongitude(), 0], '地标', '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
}
function drawpointfunc_e(event) {
var pid = getuniqueid();
drawpoint2(pid, [event.getlatitude(), event.getlongitude(), 0], markertitle, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
//drawpoint2(pid, [event.getlatitude(), event.getlongitude(), 0], markertitle, ldescription);
if (markertitle == '控制点') {
cpoints.push(pid);
}
}
function drawlinefunc_e(event) {
linestyle.line.color=lcolor;
linestyle.line.width=lwidth;
linestyle.line.opacity=lopacity;
if (objectid == '') {
objectid = getuniqueid();
// drawpathcap(objectid, [event.getlatitude(), event.getlongitude(), 0], '路径', '这是路径');
drawpathcap(objectid, [event.getlatitude(), event.getlongitude(), 0], lname, ldescription);
} else {
addpathpoint(objectid, [event.getlatitude(), event.getlongitude(), 0]);
}
}
function drawretanglefunc_e(event) {
rectanglelinestyle.width=lwidth;
rectanglelinestyle.color=lcolor;
rectanglelinestyle.opacity=lopacity;
if (objectid == '') {
objectid = getuniqueid();
//drawpoint(objectid, [event.getlatitude(), event.getlongitude(), 0], '矩形', '这是矩形');
drawpoint(objectid, [event.getlatitude(), event.getlongitude(), 0], lname, ldescription);
rubbishpoints.push(objectid);
} else {
var obj = getobjectbyid(objectid);
var geometry = obj.getgeometry();
var p0 = new geo.point(geometry.getlatitude(), geometry.getlongitude(), geometry.getaltitude());
removeobject(obj);
rubbishpoints = [];
var p2 = new geo.point(event.getlatitude(), event.getlongitude(), 0);
var p1 = gettrianglepoint(p0, p2);
var p3 = gettrianglepoint(p2, p0);
pathstyle = rectanglelinestyle;
/* drawrectangle(objectid + 'rec', [
[p0.lat(), p0.lng(), 0],
[p1.lat(), p1.lng(), 0],
[p2.lat(), p2.lng(), 0],
[p3.lat(), p3.lng(), 0]
], '矩形', '这是矩形'); */
drawrectangle(objectid + 'rec', [
[p0.lat(), p0.lng(), 0],
[p1.lat(), p1.lng(), 0],
[p2.lat(), p2.lng(), 0],
[p3.lat(), p3.lng(), 0]
], lname,ldescription);
objectid = '';
}
}
function drawpolygonfunc_e(event) {
polygonlinestyle.width=lwidth;
polygonlinestyle.color=lcolor;
polygonlinestyle.opacity=lopacity;
if (objectid == '') {
objectid = getuniqueid();
drawpoint(objectid, [event.getlatitude(), event.getlongitude(), 0], '多边形', '这是多边形');
rubbishpoints.push(objectid);
} else {
var obj = getobjectbyid(objectid);
var geometry = obj.getgeometry();
if ('kmlpoint' == geometry.gettype()) {
objectid += 'poy';
pathstyle = polygonlinestyle;
/* drawpolygoncap(objectid, [
[geometry.getlatitude(), geometry.getlongitude(), 0]
], '多边形', '这是多边形'); */
drawpolygoncap(objectid, [
[geometry.getlatitude(), geometry.getlongitude(), 0]
], lname, ldescription);
removeobject(obj);
rubbishpoints = [];
}
addpolygonpoint(objectid, [event.getlatitude(), event.getlongitude(), 0]);
}
}
function drawcirclefunc_e(c, r, a1, a2, des, name, iscircle) {
circlelinestyle.width=lwidth;
circlelinestyle.color=lcolor;
circlelinestyle.opacity=lopacity;
fanlinestyle.width=lwidth;
fanlinestyle.color=lcolor;
fanlinestyle.opacity=lopacity;
var n = 500;
var cs = c.split(',');
var cpoint = new geo.point(parsefloat(cs[1]), parsefloat(cs[0]));
var r = parsefloat(r);
var a1 = parsefloat(a1);
var a2 = parsefloat(a2);
objpoints = [];
if (math.abs(a2.sub(a1)) >= 360) {
for (var i = 0; i < n; i++) {
objpoints.push(getpointlocationbydha(cpoint, r, (360 / n) * i));
}
if (iscircle == '1') {
objpoints.push(getpointlocationbydha(cpoint, r, 360));
}
pathstyle = circlelinestyle;
drawpolygon(getuniqueid(), objpoints, (name == '') ? '圆' : name, des, iscircle);
objpoints = [];
} else {
if (iscircle == '0') {
objpoints.push(cpoint);
}
var ad = a2.sub(a1);
var adabs = math.abs(ad);
n = adabs * n.div(360);
for (var i = 0; i < n; i++) {
objpoints.push(getpointlocationbydha(cpoint, r, a1.add(ad / n * i)));
}
pathstyle = fanlinestyle;
drawpolygon(getuniqueid(), objpoints, (name == '') ? '扇形' : name, des, iscircle);
objpoints = [];
}
removeeventlistenersetcircleparams_e();
chushihuadrawfig_e();
}
var pointstyle = {
label: {
scale: 1,
color: 'white',
opacity: 1
},
icon: {
stockicon:'pushpin/ylw-pushpin',
color: 'white',
opacity: 1,
scale: 1.1
}
};
var pointstyle9 = {
label: {
scale: 1,
color: 'white',
opacity: 1
},
icon: {
href:'http://www.goodygis.com/earth/icons/xuexiao.png',
color: 'white',
opacity: 1,
scale: 2
}
};
var pointstyle1 = {
label: {
scale: 1,
color: 'white',
opacity: 1
},
icon: {
stockicon: 'shapes/flag',
color: 'white',
opacity: 1,
scale: 1.1
}
};
var pointnoiconstyle = {
label: {
scale: 1,
color: 'white',
opacity: 1
},
icon: {
stockicon: 'shapes/placemark_circle',
color: '0dffffff',
scale: 1.1
}
};
var linestyle = {
line: {
width: 3,
opacity: 1,
color: 'red'
},
icon: {
stockicon: 'paddle/red-circle'
}
};
var rulerstyle = {
line: {
width: 6,
opacity: 0.3,
color: 'red'
},
icon: {
stockicon: 'paddle/blu-stars'
}
};
var rectanglelinestyle = {
width: 3,
opacity: 1,
color: 'blue'
};
var polygonlinestyle = {
width: 3,
opacity: 1,
color: 'yellow'
};
var polygonlinestyle1 = {
width: 3,
opacity: 1,
color: '#00f9f9'
};
var circlelinestyle = {
width: 3,
opacity: 1,
color: 'fuchsia'
};
var fanlinestyle = {
width: 3,
opacity: 1,
color: 'lime'
};
var pathstyle = linestyle;
function chushihuadrawfig_e() {
if (objectid != '') {
var obj = getobjectbyid(objectid);
if ('kmlpoint' == obj.getgeometry().gettype()) {
for (var i = 0; i < rubbishpoints.length; i++) {
removeobject(getobjectbyid(rubbishpoints[i]));
}
} else if ('kmlmultigeometry' == obj.getgeometry().gettype()) {
if (obj.getgeometry().getgeometries().getchildnodes().item(1).getcoordinates().getlength() == 1) {
removeobject(obj);
} else {
drawpathrearcap(objectid);
}
} else if ('kmlpolygon' == obj.getgeometry().gettype() && obj.getgeometry().getouterboundary().getcoordinates().getlength() == 2) {
removeobject(obj);
}
}
if (rubbishpoints.length > 0) {
for (var i = 0; i < rubbishpoints.length; i++) {
removeobject(getobjectbyid(rubbishpoints[i]));
}
}
rubbishpoints = [];
objectid = '';
}
function removelastobj(n) {
var nodes = ge.getfeatures().getchildnodes();
if (nodes.getlength() > 0) {
ge.getfeatures().removechild(nodes.item(nodes.getlength() - n));
}
}
function getlastobj() {
var nodes = ge.getfeatures().getchildnodes();
return nodes.item(nodes.getlength() - 1);
}
function removeobject(obj) {
gex.dom.removeobject(obj);
downloadimgpolygonid = '';
obj = null;
window.external.setmousemovemsgbyweb('', false);
}
function removethisobject() {
getobjecttype();
if (objpoints.length > 0) {
chushihuadrawfig_e();
}
}
function clearallobjs_e() {
clearallobjects();
}
function cancellinelaststep_e() {
if (objectid != '') {
var obj = getobjectbyid(objectid);
if ('kmlmultigeometry' == obj.getgeometry().gettype()) {
var coordinates = obj.getgeometry().getgeometries().getchildnodes().item(1).getcoordinates();
if (coordinates.getlength() > 1) {
coordinates.pop();
} else {
removeobject(obj);
objectid = '';
rubbishpoints = [];
}
} else if ('kmlpolygon' == obj.getgeometry().gettype()) {
var coordinates = obj.getgeometry().getouterboundary().getcoordinates();
if (coordinates.getlength() > 2) {
coordinates.pop();
} else {
removeobject(obj);
objectid = '';
rubbishpoints = [];
}
}
}
}
function addeventlistenermeasuredistance_e() {
drawfigure_e('line');
try {
google.earth.addeventlistener(ge.getglobe(), 'mousedown', clickrightmousedrawfig);
google.earth.addeventlistener(ge.getglobe(), 'mousedown', clickrightmousemeasuredistance_e);
} catch (e) {}
pathstyle = rulerstyle;
}
function removeeventlistenermeasuredistance_e() {
figtype = '';
chushihuadrawfig_e();
dowhat = 0;
try {
google.earth.removeeventlistener(ge.getglobe(), 'mousedown', clickrightmousemeasuredistance_e);
} catch (e) {}
}
function submeasuredistance_e() {
cancellinelaststep_e();
if (objectid != '') {
gobackmeasuredistance();
}
}
var clickrightmousemeasuredistance_e = function (event) {
if (event.getbutton() == 2) {
window.external.measuredistancecallback_(computepathdistance_e(getobjectbyid(objectid)));
}
}
function gobackmeasuredistance() {
window.external.measuredistancecallback_(computepathdistance_e(getobjectbyid(objectid)));
}
function selectmeasureobject(obj) {
switch (obj.getgeometry().gettype()) {
case 'kmlmultigeometry':
var geoms = obj.getgeometry().getgeometries();
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmllinestring') {
window.external.measureobjectcallback_(0, 0, computepathdistance_e(geoms.getchildnodes().item(j)));
} else if (geoms.getchildnodes().item(j).gettype() == 'kmlpolygon') {
var params = computeareaandc(geoms.getchildnodes().item(j));
window.external.measureobjectcallback_(params[0], params[1], 0);
}
}
break;
case 'kmllinestring':
window.external.measureobjectcallback_(0, 0, computepathdistance_e(obj));
break;
case 'kmllinearring':
case 'kmlpolygon':
var params = computeareaandc(obj);
window.external.measureobjectcallback_(params[0], params[1], 0);
break;
default:
}
}
function identifyallplacemark(kmltype) {
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('gettype' in this && this.gettype() == 'kmlplacemark') {
if (this.getgeometry().gettype() == kmltype) {
bakuppoints.push({
key: this.getname(),
value: new geo.point(this.getgeometry())
});
}
}
}
});
}
function identifyobject(obj) {
if (objm == 1) {
bakuppoints = [];
switch (obj.getgeometry().gettype()) {
case 'kmlpoint':
bakuppoints.push({
key: obj.getname(),
value: new geo.point(obj.getgeometry())
});
selectobjectinfos(obj.getname(), '点', 1, 0);
break;
case 'kmllinestring':
var coords = obj.getgeometry().getcoordinates();
var length = coords.getlength();
for (var i = 0; i < length; i++) {
bakuppoints.push(new geo.point(coords.get(i)));
}
selectobjectinfos(obj.getname(), '线', 1, 1);
break;
case 'kmlpolygon':
var polygoncoords = [];
var coords = obj.getgeometry().getouterboundary().getcoordinates();
var length = coords.getlength();
var lats = [];
var lngs = [];
for (var i = 0; i < length; i++) {
lats.push(coords.get(i).getlatitude());
lngs.push(coords.get(i).getlongitude());
polygoncoords.push(getpointbylatlng(coords.get(i).getlatitude(), coords.get(i).getlongitude()));
}
var latsmax = lats.max();
var latsmin = lats.min();
var lngsmax = lngs.max();
var lngsmin = lngs.min();
bakuppoints = [creategeopointbylatlngalt(latsmax, lngsmin, 0), creategeopointbylatlngalt(latsmax, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmin, 0)];
selectobjectinfos(obj.getname(), '面', 1, 2);
polygonboundery = addpolygononmap(polygoncoords);
window.external.showdownloadimageregion(latsmax, latsmin, lngsmin, lngsmax);
break;
case 'kmlmultigeometry':
var objtype = '线';
var figuretype = 1;
var geoms = obj.getgeometry().getgeometries();
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmllinestring') {
objtype = '线';
figuretype = 1;
var coords = geoms.getchildnodes().item(j).getcoordinates();
var length = coords.getlength();
for (var i = 0; i < length; i++) {
bakuppoints.push(new geo.point(coords.get(i)));
}
} else if (geoms.getchildnodes().item(j).gettype() == 'kmlpolygon') {
objtype = '面';
figuretype = 2;
var coords = geoms.getchildnodes().item(j).getouterboundary().getcoordinates();
var length = coords.getlength();
var lats = [];
var lngs = [];
var polygoncoords = [];
for (var i = 0; i < length; i++) {
lats.push(coords.get(i).getlatitude());
lngs.push(coords.get(i).getlongitude());
polygoncoords.push(getpointbylatlng(coords.get(i).getlatitude(), coords.get(i).getlongitude()));
}
var latsmax = lats.max();
var latsmin = lats.min();
var lngsmax = lngs.max();
var lngsmin = lngs.min();
bakuppoints = [creategeopointbylatlngalt(latsmax, lngsmin, 0), creategeopointbylatlngalt(latsmax, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmin, 0)];
}
}
selectobjectinfos(obj.getname(), objtype, 1, figuretype);
if (figuretype == 2) {
polygonboundery = addpolygononmap(polygoncoords);
}
break;
default:
}
} else if (objm == 2) {
if (obj.getgeometry().gettype() == 'kmlpoint') {
bakuppoints.push({
key: obj.getname(),
value: new geo.point(obj.getgeometry())
});
selectobjectinfos(obj.getname(), '点', bakuppoints.length, 0);
} else {}
}
}
function selectobjectinfos(name, type, num, extracttype) {
var isextract = '否';
if (num > 0) {
isextract = '是';
}
window.external.autoidentifyobjectscallback_(name, type, isextract, num, extracttype);
}
var activetextbox = '';
function addeventlistenersetcircleparams_e(textbox) {
try {
google.earth.addeventlistener(ge.getglobe(), 'mousemove', movemousegetcoords_e);
google.earth.addeventlistener(ge.getglobe(), 'mousedown', clickrightmousegetcoords_e);
} catch (e) {}
activetextbox = textbox;
}
function removeeventlistenersetcircleparams_e() {
try {
google.earth.removeeventlistener(ge.getglobe(), 'mousemove', movemousegetcoords_e);
google.earth.removeeventlistener(ge.getglobe(), 'mousedown', clickrightmousegetcoords_e);
} catch (e) {}
activetextbox = '';
}
var centerpointname = '';
var movemousegetcoords_e = function (event) {
var param = '';
switch (activetextbox) {
case 'textbox1':
centerpointname = '圆心';
param = event.getlongitude().tofixed(6) + ',' + event.getlatitude().tofixed(6);
break;
case 'textbox2':
centerpointname = '半径';
var centerpoint = (window.external.gettextboxvalue('textbox1')).split(',');
if (centerpoint != '') {
param = gethorizontaldistance(new geo.point(parsefloat(centerpoint[1]), parsefloat(centerpoint[0])), new geo.point(event.getlatitude(), event.getlongitude())).tofixed(2);
} else {
activetextbox = 'textbox6';
}
break;
case 'textbox3':
centerpointname = '起始位置';
var centerpoint = (window.external.gettextboxvalue('textbox1')).split(',');
if (centerpoint != '') {
param = new geo.point(parsefloat(centerpoint[1]), parsefloat(centerpoint[0])).heading(new geo.point(event.getlatitude(), event.getlongitude())).tofixed(2);
} else {
activetextbox = 'textbox6';
}
break;
case 'textbox4':
centerpointname = '结束位置';
var centerpoint = (window.external.gettextboxvalue('textbox1')).split(',');
if (centerpoint != '') {
param = new geo.point(parsefloat(centerpoint[1]), parsefloat(centerpoint[0])).heading(new geo.point(event.getlatitude(), event.getlongitude())).tofixed(2);
} else {
activetextbox = 'textbox6';
}
break;
case 'textbox14':
centerpointname = '源点';
param = event.getlongitude() + ',' + event.getlatitude();
break;
case 'textbox15':
centerpointname = '目标点';
param = event.getlongitude() + ',' + event.getlatitude();
break;
default:
}
window.external.inputtextboxcoordscallback_(activetextbox, param);
}
var circlecenterid = '';
var circleradiusid = '';
var circlestartangleid = '';
var circleendangleid = '';
var originalpointid = '';
var targetpointid = '';
var clickrightmousegetcoords_e = function (event) {
if (event.getbutton() == 2) {
removeeventlistenersetcircleparams_e();
if (centerpointname == '圆心') {
if (circlecenterid != '') {
removeobject(getobjectbyid(circlecenterid));
}
circlecenterid = getuniqueid();
rubbishpoints.push(circlecenterid);
drawpoint(circlecenterid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else if (centerpointname == '半径') {
if (circleradiusid != '') {
removeobject(getobjectbyid(circleradiusid));
}
circleradiusid = getuniqueid();
rubbishpoints.push(circleradiusid);
drawpoint(circleradiusid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else if (centerpointname == '起始位置') {
if (circlestartangleid != '') {
removeobject(getobjectbyid(circlestartangleid));
}
circlestartangleid = getuniqueid();
rubbishpoints.push(circlestartangleid);
drawpoint(circlestartangleid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else if (centerpointname == '结束位置') {
if (circleendangleid != '') {
removeobject(getobjectbyid(circleendangleid));
}
circleendangleid = getuniqueid();
rubbishpoints.push(circleendangleid);
drawpoint(circleendangleid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else if (centerpointname == '源点') {
if (originalpointid != '') {
removeobject(getobjectbyid(originalpointid));
}
originalpointid = getuniqueid();
rubbishpoints.push(originalpointid);
drawpoint(originalpointid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else if (centerpointname == '目标点') {
if (targetpointid != '') {
removeobject(getobjectbyid(targetpointid));
}
targetpointid = getuniqueid();
rubbishpoints.push(targetpointid);
drawpoint(targetpointid, [event.getlatitude(), event.getlongitude(), 0], centerpointname, '经度:' + event.getlongitude().tofixed(6) + ',纬度:' + event.getlatitude().tofixed(6));
} else {
return false;
}
}
}
function dragplacemark() {
removeeventlistenerdrawfig_e();
if (eobj != null) {
gex.edit.makedraggable(eobj, {
bounce: false,
dropcallback: function () {}, draggingstyle: pointstyle
});
}
dowhat = 2;
}
function endeditplacemark_e() {
gex.edit.enddraggable(eobj);
eobj = null;
addeventlistenerdrawfig_e();
}
function modifyplacemark_e(name, description,linewidth,linecolor,lineopacity) {
//function modifyplacemark_e(name, description){
eobj.setname(name);
eobj.setdescription(description);
eobj.getstyleselector().getlinestyle().setwidth(linewidth);
eobj.getstyleselector().getlinestyle().getcolor().set(mergecoloropacity(linecolor, lineopacity));
}
function modifypoint_e(name, description,icon) {
eobj.setname(name);
eobj.setdescription(description);
eobj.getstyleselector().geticonstyle().geticon().sethref(icon);
}
var eobj = null;
//'word': drawpointnoiconfunc_e,
//'point': drawpointfunc_e,
//'line': drawlinefunc_e,
//'rectangle': drawretanglefunc_e,
//'polygon': drawpolygonfunc_e
//编辑选择的对象
function editobject(obj) {
var id = '';
var name = '';
var des = '';
//alert(obj.getgeometry().gettype());
if (obj.getgeometry().gettype() == 'kmlpolygon' ||
obj.getgeometry().gettype() == 'kmlmultigeometry' || obj.getgeometry().gettype() == 'kmllinestring' ) {
eobj = obj;
//alert(obj.getstyleselector().geticonstyle().geticon().gethref());获得图标的地址
//alert(obj.getstyleselector().getlinestyle().getwidth());获得线的宽度
//alert(obj.getstyleselector().getlinestyle().getcolor().get());获得线的颜色和透明度,是一个八位的字符串,前两位是透明度,后面六位是颜色,分别是蓝、绿、红
window.external.editotherscallback_(obj.getname(), obj.getdescription(),obj.getstyleselector().getlinestyle().getwidth(),obj.getstyleselector().getlinestyle().getcolor().get());
} else if(obj.getgeometry().gettype() == 'kmlpoint' )
{
eobj = obj;
window.external.editkmlpointcallback_(obj.getname(),obj.getdescription(),obj.getstyleselector().geticonstyle().geticon().gethref());//
}
else if ('getid' in obj && obj.getgeometry().gettype() == 'kmllinestring') {}
else if ('getid' in obj && obj.getgeometry().gettype() == 'kmllinearring') {}
else if ('getid' in obj && obj.getgeometry().gettype() == 'kmlpolygon') {}
else if ('getid' in obj && obj.getgeometry().gettype() == 'kmlmodel') {}
else {}
}
function updatepoint(oid, labelname, description, labelcolor, labelscale, labelopacity, iconcolor, iconscale, iconopacity, systemicon, ownicon, altitude, altitudemode) {
var obj = getobjectbyid(oid);
obj.setname(labelname);
obj.setdescription(description);
obj.getstyleselector().geticonstyle().setscale(iconscale);
}
function updateline(oid, linename, linedescription, linewidth, linecolor, lineopacity) {
var obj = getobjectbyid(oid);
obj.setname(linename);
obj.setdescription(linedescription);
obj.getstyleselector().getlinestyle().setwidth(linewidth);
obj.getstyleselector().getlinestyle().getcolor().set(mergecoloropacity(linecolor, lineopacity));
}
function updatepolygon(oid, linename, linedescription, linewidth, linecolor, lineopacity, polycolor, polyopacity) {
var obj = getobjectbyid(oid);
obj.setname(linename);
obj.setdescription(linedescription);
obj.getstyleselector().getlinestyle().setwidth(linewidth);
obj.getstyleselector().getlinestyle().getcolor().set(mergecoloropacity(linecolor, lineopacity));
obj.getstyleselector().getpolystyle().getcolor().set(mergecoloropacity(polycolor, polyopacity));
}
function removepointbyid(id) {
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('gettype' in this && this.gettype() == 'kmlplacemark') {
if ('gettype' in this.getgeometry() && this.getgeometry().gettype() == 'kmlpoint') {
if ('getid' in this && this.getid() == id) {
removeobject(this);
}
}
}
}
});
}
function removepointbyname(name) {
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('gettype' in this && this.gettype() == 'kmlplacemark') {
if ('gettype' in this.getgeometry() && this.getgeometry().gettype() == 'kmlpoint') {
if ('getname' in this && this.getname() == name) {
removeobject(this);
}
}
}
}
});
}
function getobjecttype() {
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('gettype' in this && this.gettype() == 'kmlplacemark') {
if (this.getgeometry().gettype() == 'kmlpoint') {} else if (this.getgeometry().gettype() == 'kmllinestring') {}
}
}
});
}
function removeoldpoly() {
var nodes = ge.getfeatures().getchildnodes();
var nodeslength = nodes.getlength();
for (var i = 2; i < nodeslength; i++) {
ge.getfeatures().removechild(nodes.item(i));
}
}
function clearallobjects() {
try {
gex.dom.clearfeatures();
bakuppoints = [];
points = [];
objectid = '';
cpoints = [];
} catch (err) {}
}
//修改后的全部清除
function clearalldrawobjects() {
var nodes=ge.getfeatures().getchildnodes();
var nodeslength=nodes.getlength();
for (var i = 0; i < nodeslength; i++) {
if(nodes.item(i).gettype()=='kmlplacemark')
{
ge.getfeatures().removechild(nodes.item(i));
}
}
bakuppoints = [];
points = [];
objectid = '';
cpoints = [];
}
function removelastobject(num) {
var nodes = ge.getfeatures().getchildnodes();
var nodeslength = nodes.getlength();
if (nodeslength == 1) {
ge.getfeatures().removechild(nodes.item(0));
} else {
for (var i = nodeslength - num; i < nodeslength && i >= 0; i++) {
ge.getfeatures().removechild(nodes.item(i));
}
}
bakuppoints.pop();
}
function setoriginpoints() {
cancelwebbrowserrun('run');
points = bakuppoints.slice(0);
pmcount = points.length;
extracttimes = 0;
ppoints = [];
apoints = [];
xnum = 0;
ynum = 0;
fzd = 1;
zxz = 1;
dlzx = [];
pbounds = null;
ppaths = null;
}
function cleartallparams() {
pcount = 0;
extracttimes = 0;
ppoints = [];
xnum = 0;
ynum = 0;
}
function setearthstate(point, flyspeed, range) {
if (flyspeed == 6) {
flyspeed = ge.speed_teleport;
}
movemaptopoint(point, range, flyspeed, null);
}
function calpointsnum() {
setoriginpoints();
if (points.length == 0) {
alert('对不起,请设置要提取高程的对象!');
return;
}
window.external.calpointsovercallback_(points.length, '');
}
function callinespointsnum(d) {
setoriginpoints();
if (points.length == 0) {
alert('请设置路线!');
return;
}
try {
var pacount;
var pcount = 0;
var hd = 0;
var d = 0;
var setpointsnum = points.length;
for (var i = 1; i < setpointsnum; i++) {
hd = gethorizontaldistance(points[i - 1], points[i]);
d = parsefloat(d).add(parsefloat(hd));
}
pacount = math.floor(parsefloat(d).div(parsefloat(d)));
pcount = pcount + pacount + 1;
if (window.external.isbaohanguaidian() == '1') {
pcount = pcount + setpointsnum - 2;
}
window.external.calpointsovercallback_(pcount, d.tofixed(2));
} catch (err) {
}
}
function callinevertexpointsnum() {
setoriginpoints();
var length = points.length;
if (length == 0) {
alert('请设置路线!');
return;
}
var hd = 0;
var d = 0;
for (var i = 1; i < length; i++) {
hd = gethorizontaldistance(points[i - 1], points[i]);
d = parsefloat(d).add(parsefloat(hd));
}
window.external.calpointsovercallback_(length, d.tofixed(2));
}
function caldlinespointsnum(d, w) {
setoriginpoints();
if (points.length == 0) {
alert('请设置路线!');
return;
}
try {
d = parsefloat(d);
w = parsefloat(w);
var pacount;
var pcount = 0;
var hd = 0;
var d = 0;
var setpointsnum = points.length;
for (var i = 1; i < setpointsnum; i++) {
hd = gethorizontaldistance(points[i - 1], points[i]);
pcount += math.floor(hd.div(d)) + 1;
}
pcount += 1;
if (window.external.isbaohanguaidian() == '1') {
pcount = pcount + setpointsnum - 2;
}
window.external.calpointsovercallback_((2 * math.floor(w / d) + 1) * pcount, d.tofixed(2));
} catch (err) {
}
}
var ppoints = [];
var apoints = [];
function calpolypointsnum(d) {
var stats = []
setoriginpoints();
if (points.length == 0) {
window.external.stoprun('请绘制并选择矩形或者多边形!');
return;
}
try {
var apoly = gethorizontaldistance(points[0], points[1]).tofixed(2);
var bpoly = gethorizontaldistance(points[0], points[3]).tofixed(2);
var temp = 0;
if (parsefloat(apoly) < parsefloat(bpoly)) {
temp = bpoly;
bpoly = apoly;
apoly = temp;
points = [points[0], points[3], points[2], points[1]];
rotatemap(0);
} else {
rotatemap(90);
}
var anum = math.ceil(parsefloat(apoly).div(parsefloat(d))) + 1;
var bnum = math.ceil(parsefloat(bpoly).div(parsefloat(d))) + 1;
var pointsnum = parsefloat(anum).mul(parsefloat(bnum));
var area = parsefloat(apoly).mul(parsefloat(bpoly));
apoints[0] = getpointlocationbydh(points[0], points[1], d / 5);
apoints[1] = getpointlocationbydh(points[1], points[2], d / 5);
apoints[3] = getpointlocationbydh(points[3], points[2], d / 5);
apoints[0] = getpointlocationbydh(apoints[0], apoints[3], d / 5);
apoints[2] = points[2];
polyparams = [apoints[0], apoints[0], anum, bnum, anum, area, pointsnum];
ppoints[0] = apoints[0];
var parea = computeareaandc(polygoncontourobj);
try {
window.external.calpointsovercallback_(parseint(parea[1] / area * pointsnum), parea[1]);
} catch (err) {
}
pbounds = polygonboundery.getbounds();
ppaths = polygonboundery.getpaths();
} catch (err) {
}
}
function extractpointselevationsquick() {
var data = '[';
var placemarkcount = points.length;
for (var i = 0; i < placemarkcount; i++) {
data += '{n:"' + points[i].key + '",w:"' + points[i].value.lat().tofixed(6) + '",j:"' + points[i].value.lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(points[i].value.lat(), points[i].value.lng()).tofixed(3) + '"},';
}
data += ']';
window.external.extractelevationsokcallback_(data, placemarkcount);
data = '';
}
var pmcount = 0;
function extractpointselevations(v, t) {
pcount = 0;
extractpointelevation(v, t);
}
function extractpointelevation(v, t) {
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
var range = 10;
if (pcount == 0) {
movemaptopoint(points[0].value, range, 6, null);
data = '[';
pcount++;
settimeout('extractpointelevation(' + v + ',' + window.external.getextracteledylaytime() + ')', t);
return false;
}
data += '{n:"' + points[0].key + '",w:"' + points[0].value.lat().tofixed(6) + '",j:"' + points[0].value.lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(points[0].value.lat(), points[0].value.lng()).tofixed(3) + '"},';
if (points.length > 0) {
points.splice(0, 1);
}
window.external.extractingelevationscallback_(data, pcount);
data = '';
if (points.length > 0) {
movemaptopoint(points[0].value, range, 6, null);
pcount++;
settimeout('extractpointelevation(' + v + ',' + window.external.getextracteledylaytime() + ')', t);
return false;
} else {
window.external.extractelevationsokcallback_(']', pcount);
pcount = 0;
}
data = '';
}
var dd = 0;
function extractpathvertexelevations(v, t) {
pcount = 0;
dd = 0;
extractpathvertexelevation(v, t);
}
function extractpathvertexelevation(v, t) {
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
var range = 10;
if (pcount == 0) {
dd = 0;
movemaptopoint(points[0], range, 6, null);
data = '[';
pcount++;
settimeout('extractpathvertexelevation(' + v + ',' + window.external.getextracteledylaytime() + ')', t);
return false;
}
data += '{w:"' + points[0].lat().tofixed(6) + '",j:"' + points[0].lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(points[0].lat(), points[0].lng()).tofixed(3) + '",d:"' + dd.tofixed(2) + '"},';
var length = points.length;
if (length > 0) {
if (length > 1) {
dd = dd.add(gethorizontaldistance(points[0], points[1]));
}
points.splice(0, 1);
}
window.external.extractingelevationscallback_(data, pcount);
data = '';
if (points.length > 0) {
movemaptopoint(points[0], range, 6, null);
pcount++;
settimeout('extractpathvertexelevation(' + v + ',' + t + ')', t);
return false;
} else {
dd = 0;
window.external.extractelevationsokcallback_(']', pcount);
pcount = 0;
}
data = '';
}
function extractpathvertexelevationsquick() {
var data = '[';
var placemarkcount = points.length;
var d = 0;
for (var i = 0; i < placemarkcount; i++) {
data += '{w:"' + points[i].lat().tofixed(6) + '",j:"' + points[i].lng().tofixed(6) + '",a:"' + ge.getglobe().getgroundaltitude(points[i].lat(), points[i].lng()).tofixed(3) + '",d:"' + d.tofixed(2) + '"},';
if (i + 1 < placemarkcount) {
d = d.add(gethorizontaldistance(points[i], points[i + 1]));
}
}
data += ']';
window.external.extractelevationsokcallback_(data, placemarkcount);
data = '';
d = 0;
}
var data = '';
var pcount = 0;
function extractlineselevations(d, p, v, t, dlzx) {
var range = 2 * d * p + 20;
movemaptopoint(points[0], range, 5, null);
data = '[';
pcount = 0;
if (dlzx == "1") {
settimeout('extractdlzxpathelevation(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ');', 2000);
} else {
settimeout('extractpathelevation(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ');', 2000);
}
}
var fzd = 1;
var zxz = 1;
var dlzx = [];
function extractdlzxpathelevation(d, p, range, v, t) {
var pacount = 0;
var hd = 0;
var ipoint = null;
var movepoint = null;
var heading;
if (extracttimes == 0) {
pcount = 1;
extracttimes++;
data += returndlzxpointjson(points[0], 'j1', 0);
dlzx = [points[0].lat().tofixed(6), points[0].lng().tofixed(6), ge.getglobe().getgroundaltitude(points[0].lat(), points[0].lng()).tofixed(3), false, 'j'];
}
var setpointsnum = points.length;
for (var i = 1; i < setpointsnum; i++) {
pacount = 0;
hd = points[i - 1].distance(points[i]);
if (parsefloat(hd) > parsefloat(d)) {
pacount = math.floor(parsefloat(hd).div(parsefloat(d)));
ipoint = points[i - 1];
movepoint = geo.math.destination(ipoint, {
distance: d * p,
heading: ipoint.heading(points[i])
});
for (var j = p; j <= pacount + p; j = j + p) {
movemaptopoint(movepoint, range, v);
sleep(window.external.getextracteledylaytime());
for (var z = p; z >= 1 && j - z < pacount; z--) {
ipoint = geo.math.destination(ipoint, {
distance: d,
heading: ipoint.heading(points[i])
});
pcount++;
data += returndlzxapointjson(ipoint);
if (pcount % p == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
if (j + p > pacount) {
movepoint = points[i];
if (j > pacount) {
ipoint = points[i];
}
} else {
movepoint = geo.math.destination(ipoint, {
distance: d * (p + 1),
heading: ipoint.heading(points[i])
});
}
}
}
pcount++;
data += returndlzxbpointjson(points[i], 'j' + (i + 1), 0);
dlzx = [points[i].lat().tofixed(6), points[i].lng().tofixed(6), ge.getglobe().getgroundaltitude(points[i].lat(), points[i].lng()).tofixed(3), false, 'j'];
if (pcount % p == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
}
data += ']';
window.external.extractelevationsokcallback_(data, pcount);
data = '';
}
function extractpathelevation(d, p, range, v, t) {
var pacount = 0;
var hd = 0;
var e = 0;
var ipoint = null;
var movepoint = null;
var heading = 0;
window.external.extractingelevationscallback_('', 0);
var isgd = window.external.isbaohanguaidian() == '1' ? true : false;
if (extracttimes == 0) {
pcount = 1;
extracttimes++;
data += returnpointjson(points[0]);
}
var setpointsnum = points.length;
for (var i = 1; i < setpointsnum; i++) {
ipoint = points[i - 1];
heading = points[i - 1].heading(points[i]);
hd = gethorizontaldistance(points[i - 1], points[i]).add(e);
for (var j = 1; j <= hd.div(d); j++) {
if (j == 1) {
ipoint = getpointlocationbydha(ipoint, d.sub(e), heading);
} else {
ipoint = getpointlocationbydha(ipoint, d, heading);
}
pcount++;
data += returnpointjson(ipoint);
if (pcount % 10 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
if ((pcount - 2) % p == 0) {
var hdd = 0;
hdd = hdd.add(gethorizontaldistance(ipoint, points[i]));
if (hdd >= p * d) {
movepoint = getpointlocationbydha(ipoint, p * d, ipoint.heading(points[i]));
} else {
hdd = (p * d).sub(hdd);
for (var k = i; k < 1000000000000; k++) {
if (k < setpointsnum - 1) {
var dd = gethorizontaldistance(points[k], points[k + 1]);
if (hdd <= dd) {
movepoint = getpointlocationbydha(points[k], hdd, points[k].heading(points[k + 1]));
break;
} else {
hdd = hdd.sub(dd);
}
} else {
movepoint = points[setpointsnum - 1];
break;
}
}
}
heading = ipoint.heading(points[i]);
movemaptopoint(movepoint, range, v, null);
sleep(window.external.getextracteledylaytime());
}
}
e = hd % d;
if (isgd) {
pcount++;
data += returnpointjson(points[i]);
if (pcount % 10 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
}
}
data += ']';
window.external.extractelevationsokcallback_(data, pcount);
data = '';
}
function extractlineselevationsquick(d) {
data = '[';
var pacount = 0;
pcount = 0;
var hd = 0;
var e = 0;
var heading = 0;
var ipoint = null;
window.external.extractingelevationscallback_('', 0);
var isgd = window.external.isbaohanguaidian() == '1' ? true : false;
if (extracttimes == 0) {
pcount = 1;
extracttimes++;
data += returnpointjson(points[0]);
}
var setpointsnum = points.length;
for (var i = 1; i < setpointsnum; i++) {
ipoint = points[i - 1];
heading = points[i - 1].heading(points[i]);
hd = gethorizontaldistance(points[i - 1], points[i]).add(e);
for (var j = 1; j <= parseint(hd.div(d)); j++) {
if (j == 1) {
ipoint = getpointlocationbydha(ipoint, parsefloat(d).sub(e), heading);
} else {
ipoint = getpointlocationbydha(ipoint, d, heading);
}
pcount++;
data += returnpointjson(ipoint);
if (pcount % 1000 == 0) {
heading = ipoint.heading(points[i]);
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
e = hd % d;
if (isgd) {
pcount++;
data += returnpointjson(points[i]);
if (pcount % 1000 == 0) {
heading = ipoint.heading(points[i]);
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
}
}
window.external.extractelevationsokcallback_(data + ']', pcount);
data = '';
pcount = 0;
}
function extractdlineselevationsquick(d, w) {
d = parsefloat(d);
w = parsefloat(w);
data = '[';
pcount = 0;
var hd = 0;
var vn = math.floor(w / d);
var hn = 0;
var heading = 0;
var ipoint = null;
var vn1point;
var vn2point;
window.external.extractingelevationscallback_('', 0);
if (extracttimes == 0) {
extracttimes++;
}
var setpointsnum = points.length;
for (var i = 0; i < setpointsnum - 1; i++) {
if (i == 0) {
heading = points[0].heading(points[1]);
hd = gethorizontaldistance(points[0], points[1]);
hn = math.floor(hd / d);
} else {
heading = points[i].heading(points[i + 1]);
hd = gethorizontaldistance(points[i], points[i + 1]);
hn = math.floor(hd / d);
}
for (var j = 0; j <= hn + 1; j++) {
if (j == 0) {
if (i == 0) {
ipoint = points[0];
} else {
continue;
}
} else if (j == hn + 1) {
ipoint = points[i + 1];
if (i < setpointsnum - 2) {
heading = points[i + 1].heading(points[i + 2]);
}
} else {
ipoint = getpointlocationbydha(ipoint, d, heading);
}
data += returnpointjson(ipoint);
pcount++;
if (pcount % 1000 == 0) {
heading = ipoint.heading(points[i + 1]);
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
for (var g = 1; g <= vn; g++) {
var vn1point = getpointlocationbydha(ipoint, d * g, heading + 90);
data += returnpointjson(vn1point);
pcount++;
if (pcount % 1000 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
var vn2point = getpointlocationbydha(ipoint, d * g, heading - 90);
data += returnpointjson(vn2point);
pcount++;
if (pcount % 1000 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
}
}
}
window.external.extractelevationsokcallback_(data + ']', pcount);
data = '';
pcount = 0;
}
function extractdlineselevations(d, p, v, t, w) {
var range = 2 * d * p + 20;
movemaptopoint(points[0], range, 5, null);
pcount = 0;
settimeout('extractdpathelevation(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ',' + w + ');', 2000);
}
function extractdpathelevation(d, p, range, v, t, w) {
data = '[';
pcount = 0;
var hd = 0;
var vn = math.floor(w / d);
var hn = 0;
var heading = 0;
var ipoint = null;
var vn1point;
var vn2point;
var movepoint;
window.external.extractingelevationscallback_('', 0);
if (extracttimes == 0) {
extracttimes++;
}
var setpointsnum = points.length;
for (var i = 0; i < setpointsnum - 1; i++) {
if (i == 0) {
heading = points[0].heading(points[1]);
hd = gethorizontaldistance(points[0], points[1]);
hn = math.floor(hd / d);
} else {
heading = points[i].heading(points[i + 1]);
hd = gethorizontaldistance(points[i], points[i + 1]);
hn = math.floor(hd / d);
}
for (var j = 0; j <= hn + 1; j++) {
if (j == 0) {
if (i == 0) {
ipoint = points[0];
} else {
continue;
}
} else if (j == hn + 1) {
ipoint = points[i + 1];
if (i < setpointsnum - 2) {
heading = points[i + 1].heading(points[i + 2]);
}
} else {
ipoint = getpointlocationbydha(ipoint, d, heading);
}
if (j % p == 0) {
movepoint = geo.math.destination(ipoint, {
distance: d * p,
heading: heading
});
movemaptopoint(movepoint, range, v, null);
sleep(window.external.getextracteledylaytime());
}
data += returnpointjson(ipoint);
pcount++;
if (pcount % 20 == 0) {
heading = ipoint.heading(points[i + 1]);
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
for (var g = 1; g <= vn; g++) {
var vn1point = getpointlocationbydha(ipoint, d * g, heading + 90);
data += returnpointjson(vn1point);
pcount++;
if (pcount % 20 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
var vn2point = getpointlocationbydha(ipoint, d * g, heading - 90);
data += returnpointjson(vn2point);
pcount++;
if (pcount % 20 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
points.splice(0, i, ipoint);
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
}
}
}
window.external.extractelevationsokcallback_(data + ']', pcount);
data = '';
}
var hheading;
var vheading;
var pbounds;
var ppaths;
function extractpolyelevations(d, p, v, t) {
var range = 2 * d * p + 200;
if (extracttimes == 0) {
hheading = polyparams[0].heading(apoints[1]);
vheading = polyparams[0].heading(apoints[3]);
getrectanglepoints(ppoints[0], d, p);
ppoints[4] = 0;
ppoints[5] = 0;
}
movemaptopoint(getpointlocationbydha(ppoints[1], d * (p - 1), vheading), range, 5, null);
settimeout('extractpolyelevation(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ');', 2000);
}
var qpoint = null;
var hpoint = null;
var qqpoint = null;
var xnum = 0;
var ynum = 0;
function extractpolyelevation(d, p, range, v, t) {
var anum = polyparams[2];
var bnum = polyparams[3];
pcount = 0;
var xpoint = null;
var ypoint = null;
var mpoint = null;
var point = null;
var data = '[';
window.external.extractingelevationscallback_('', 0);
for (var i = ynum; i < bnum; i = i + 2 * p - 1) {
for (var j = xnum; j < anum; j = j + p) {
if (j == 0) {
qpoint = ppoints[3];
}
ypoint = ppoints[0];
for (var y = ppoints[4]; y <= 2 * (p - 1); y++) {
if (i + y + 2 > bnum) {
break;
}
xpoint = getpointlocationbydha(ypoint, d * y, vheading);
for (var x = ppoints[5]; x < p; x++) {
if (j + x + 2 > anum) {
break;
}
point = getpointlocationbydha(xpoint, d * x, hheading);
var coordinate = getpointbylatlng(point.lat(), point.lng());
if (!iscontainslatlng(pbounds, ppaths, coordinate)) {
continue;
}
pcount++;
data += returnpointjson(point);
if (pcount % 100 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
ynum = i;
xnum = j;
ppoints[4] = y;
ppoints[5] = x + 1;
extracttimes++;
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
ppoints[5] = 0;
}
ppoints[4] = 0;
xnum = 0;
getrectanglepoints(ppoints[1], d, p);
mpoint = getpointlocationbydha(ppoints[1], d * (p - 1), vheading);
movemaptopoint(mpoint, range, 5, null);
if (pcount == 0 || pcount % 100 != 0) {
window.external.extractingelevationscallback_('', pcount);
}
sleep(window.external.getextracteledylaytime());
}
getrectanglepoints(getpointlocationbydha(qpoint, d, vheading), d, p);
mpoint = getpointlocationbydha(ppoints[1], d * (p - 1), vheading);
movemaptopoint(mpoint, range, 5, null);
sleep(window.external.getextracteledylaytime());
}
ynum = 0;
movemaptopoint(polyparams[0], d * anum, 5, null);
window.external.extractelevationsokcallback_(data + ']', pcount);
data = '';
}
function extractpolyelevationsquick(d) {
var pcount = 0;
var pjcount;
var data = '[';
var jpoint = null;
var ipoint = null;
var anum = polyparams[2];
var bnum = polyparams[3];
ipoint = polyparams[0];
window.external.extractingelevationscallback_('', 0);
for (var i = 1; i < bnum; i++) {
for (var j = 1; j < anum; j++) {
if (j == 1) {
if (extracttimes == 0) {
jpoint = ipoint;
} else {
jpoint = polyparams[1];
extracttimes = 0;
}
} else {
jpoint = getpointlocationbydha(jpoint, d, jpoint.heading(apoints[1]));
}
var coordinate = getpointbylatlng(jpoint.lat(), jpoint.lng());
if (!iscontainslatlng(pbounds, ppaths, coordinate)) {
continue;
}
pcount++;
data += returnpointjson(jpoint);
if (pcount % 1000 == 0) {
window.external.extractingelevationscallback_(data, pcount);
if (pcount % 65000 == 0) {
polyparams[0] = ipoint;
if (j == anum) {
polyparams[1] = getpointlocationbydha(ipoint, d, ipoint.heading(apoints[3]));
} else {
polyparams[1] = getpointlocationbydha(jpoint, d, jpoint.heading(apoints[1]));
}
polyparams[3] = bnum - i + 1;
polyparams[2] = anum - j;
extracttimes++;
window.external.extractelevationscallback_(']', pcount);
data = '';
return false;
}
data = '';
}
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
}
anum = polyparams[4];
ipoint = getpointlocationbydha(ipoint, d, ipoint.heading(apoints[3]));
apoints[1] = getpointlocationbydha(apoints[1], d, apoints[1].heading(apoints[2]));
}
window.external.extractelevationsokcallback_(data + ']', pcount);
data = '';
}
function getcorrectcoordsparams(oplng, oplat, tplng, tplat) {
var opoint = new geo.point(oplat, oplng);
var tpoint = new geo.point(tplat, tplng);
var heading = opoint.heading(tpoint);
var d = gethorizontaldistance(opoint, tpoint);
return d + ',' + heading;
}
function correctfigcoords_e(d, h, flag) {
gex.dom.walk({
rootobject: ge,
visitcallback: function () {
if ('gettype' in this && this.gettype() == 'kmlplacemark') {
correctcoords(this, d, h, flag);
}
}
});
}
function correctcoords(obj, d, heading, flag) {
var destpoint = null;
var paths = [];
switch (obj.getgeometry().gettype()) {
case 'kmlpoint':
if (flag == 0) {
if (obj.getname() == '源点' || obj.getname() == '目标点') {
return;
}
destpoint = getpointlocationbydha(new geo.point(obj.getgeometry()), d, heading);
} else if (flag == 1) {
var p = window.external.m2w(obj.getgeometry().getlatitude() + ',' + obj.getgeometry().getlongitude());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
} else {
var p = window.external.w2m(obj.getgeometry().getlatitude() + ',' + obj.getgeometry().getlongitude());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
}
obj.getgeometry().setlatitude(destpoint.lat());
obj.getgeometry().setlongitude(destpoint.lng());
break;
case 'kmllinestring':
var coords = obj.getgeometry().getcoordinates();
var length = coords.getlength();
if (flag == 0) {
for (var i = 0; i < length; i++) {
paths.push(getpointlocationbydha(new geo.point(coords.get(i)), d, heading));
}
} else {
var sl = '';
for (var i = 0; i < length; i++) {
sl += i > 0 ? ';' : '';
sl += coords.get(i).getlatitude() + ',' + coords.get(i).getlongitude();
}
if (flag == 1) {
var pl = window.external.m2w(sl);
} else {
var pl = window.external.w2m(sl);
}
sl = '';
var pls = pl.split(';');
pl = '';
for (var i = 0; i < length; i++) {
var cl = pls[i].split(',');
paths.push(new geo.point(parsefloat(cl[0]), parsefloat(cl[1])));
}
}
coords.clear();
for (var i = 0; i < length; i++) {
coords.pushlatlngalt(paths[i].lat(), paths[i].lng(), 0);
}
paths = [];
break;
case 'kmlpolygon':
var coords = obj.getgeometry().getouterboundary().getcoordinates();
var length = coords.getlength();
if (flag == 0) {
for (var i = 0; i < length; i++) {
paths.push(getpointlocationbydha(new geo.point(coords.get(i)), d, heading));
}
} else {
var sl = '';
for (var i = 0; i < length; i++) {
sl += i > 0 ? ';' : '';
sl += coords.get(i).getlatitude() + ',' + coords.get(i).getlongitude();
}
if (flag == 1) {
var pl = window.external.m2w(sl);
} else {
var pl = window.external.w2m(sl);
}
sl = '';
var pls = pl.split(';');
pl = '';
for (var i = 0; i < length; i++) {
var cl = pls[i].split(',');
paths.push(new geo.point(parsefloat(cl[0]), parsefloat(cl[1])));
}
}
coords.clear();
for (var i = 0; i < length; i++) {
coords.pushlatlngalt(paths[i].lat(), paths[i].lng(), 0);
}
paths = [];
break;
case 'kmlmultigeometry':
var geoms = obj.getgeometry().getgeometries();
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmllinestring') {
var coords = geoms.getchildnodes().item(j).getcoordinates();
var length = coords.getlength();
paths = [];
if (flag == 0) {
for (var i = 0; i < length; i++) {
paths.push(getpointlocationbydha(new geo.point(coords.get(i)), d, heading));
}
} else {
var sl = '';
for (var i = 0; i < length; i++) {
sl += i > 0 ? ';' : '';
sl += coords.get(i).getlatitude() + ',' + coords.get(i).getlongitude();
}
if (flag == 1) {
var pl = window.external.m2w(sl);
} else {
var pl = window.external.w2m(sl);
}
sl = '';
var pls = pl.split(';');
pl = '';
for (var i = 0; i < length; i++) {
var cl = pls[i].split(',');
paths.push(new geo.point(parsefloat(cl[0]), parsefloat(cl[1])));
}
}
coords.clear();
for (var i = 0; i < length; i++) {
coords.pushlatlngalt(paths[i].lat(), paths[i].lng(), 0);
}
} else if (geoms.getchildnodes().item(j).gettype() == 'kmlpoint') {
if (flag == 0) {
destpoint = getpointlocationbydha(new geo.point(geoms.getchildnodes().item(j).getlatitude(), geoms.getchildnodes().item(j).getlongitude()), d, heading);
} else if (flag == 1) {
var p = window.external.m2w(geoms.getchildnodes().item(j).getlatitude() + ',' + geoms.getchildnodes().item(j).getlongitude());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
} else {
var p = window.external.w2m(geoms.getchildnodes().item(j).getlatitude() + ',' + geoms.getchildnodes().item(j).getlongitude());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
}
geoms.getchildnodes().item(j).setlatitude(destpoint.lat());
geoms.getchildnodes().item(j).setlongitude(destpoint.lng());
}
}
paths = [];
break;
default:
}
}
function correctkmlcoords(d, heading, kmlstring, flag) {
var destpoint = null;
try {
var xmldoc2 = new activexobject('microsoft.xmldom');
xmldoc2.async = 'false';
xmldoc2.loadxml(kmlstring);
var docroot = xmldoc2.documentelement;
var pmarray = docroot.selectnodes('//coordinates');
var pmcount = pmarray.length;
var alts = [];
for (var i = 0; i < pmcount; i++) {
var coords = pmarray[i].text.trim().replace(/\n/g, ' ').replace(/\s+/g, ' ').split(' ');
var coordcount = coords.length;
var coordstr = '';
if (flag == 0) {
for (var j = 0; j < coordcount; j++) {
var coord = coords[j].split(',');
destpoint = getpointlocationbydha(new geo.point(parsefloat(coord[1]), parsefloat(coord[0]), parsefloat(coord[2])), d, heading);
coordstr += destpoint.lng() + ',' + destpoint.lat() + ',' + destpoint.altitude() + ' ';
}
} else {
var s = '';
for (var j = 0; j < coordcount; j++) {
var coord = coords[j].split(',');
s += j > 0 ? ';' : '';
s += coord[1] + ',' + coord[0];
alts[j] = coord[2];
}
var p = window.external.m2w(s);
s = '';
var ps = p.split(';');
p = '';
for (var j = 0; j < coordcount; j++) {
var cl = ps[j].split(',');
coordstr += cl[1] + ',' + cl[0] + ',' + alts[j] + ' ';
}
alts = [];
}
pmarray[i].text = coordstr;
}
} catch (err) {
alert('解析kml文件错误,请检测文件格式!');
}
var kml = '<?xml version="1.0" encoding="utf-8"?>\r\n' + docroot.xml;
docroot = null;
xmldoc2 = null;
return formatkmlforhtml(kml);;
}
var polygonboundery = null;
var polygoncontourobj = null;
function getobjectbounds(obj) {
var polygoncoords = [];
polygonboundery = null;
polygoncontourobj = null;
if (obj.getgeometry().gettype() == 'kmlpolygon') {
var coords = obj.getgeometry().getouterboundary().getcoordinates();
var length = coords.getlength();
var lats = [];
var lngs = [];
var boundery = (length + 1) + ',' + 0;
for (var i = 0; i < length; i++) {
lats.push(coords.get(i).getlatitude());
lngs.push(coords.get(i).getlongitude());
boundery += '\r\n' + coords.get(i).getlongitude().tofixed(8) + ' ' + coords.get(i).getlatitude().tofixed(8);
polygoncoords.push(getpointbylatlng(coords.get(i).getlatitude(), coords.get(i).getlongitude()));
}
boundery += '\r\n' + coords.get(0).getlongitude().tofixed(8) + ' ' + coords.get(0).getlatitude().tofixed(8);
var latsmax = lats.max();
var latsmin = lats.min();
var lngsmax = lngs.max();
var lngsmin = lngs.min();
bakuppoints = [creategeopointbylatlngalt(latsmax, lngsmin, 0), creategeopointbylatlngalt(latsmax, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmin, 0)];
if (length > 2) {
window.external.getcontourregioncallback_(boundery);
polygonboundery = addpolygononmap(polygoncoords);
polygoncontourobj = obj;
}
} else if (obj.getgeometry().gettype() == 'kmlmultigeometry') {
var geoms = obj.getgeometry().getgeometries();
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmlpolygon') {
var coords = geoms.getchildnodes().item(j).getouterboundary().getcoordinates();
var length = coords.getlength();
var lats = [];
var lngs = [];
var boundery = (length + 1) + ',' + 0;
for (var i = 0; i < length; i++) {
lats.push(coords.get(i).getlatitude());
lngs.push(coords.get(i).getlongitude());
boundery += '\r\n' + coords.get(i).getlongitude().tofixed(8) + ' ' + coords.get(i).getlatitude().tofixed(8);
polygoncoords.push(getpointbylatlng(coords.get(i).getlatitude(), coords.get(i).getlongitude()));
}
boundery += '\r\n' + coords.get(0).getlongitude().tofixed(8) + ' ' + coords.get(0).getlatitude().tofixed(8);
var latsmax = lats.max();
var latsmin = lats.min();
var lngsmax = lngs.max();
var lngsmin = lngs.min();
bakuppoints = [creategeopointbylatlngalt(latsmax, lngsmin, 0), creategeopointbylatlngalt(latsmax, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmax, 0), creategeopointbylatlngalt(latsmin, lngsmin, 0)];
if (length > 2) {
window.external.getcontourregioncallback_(boundery);
polygonboundery = addpolygononmap(polygoncoords);
polygoncontourobj = obj;
}
}
}
} else {
window.external.identifyregionfailed();
}
}
function addpolygononmap(coords) {
return new google.maps.polygon({
title: '',
paths: coords,
strokecolor: "#ff0000",
strokeopacity: 0.8,
strokeweight: 2,
fillcolor: "#ff0000",
fillopacity: 0.05
});
}
var cps = [];
function extractcontrolpoints(d) {
if (cps.length > 0) {
var v = 6;
var t = 3000;
pcount = 0;
data = '';
movemaptopoint(cps[0].value, 10, 6, null);
settimeout('extractcontrolpoint(' + v + ',' + t + ')', 2000);
} else {
extractpolyelevationsforcontour(d);
}
}
function extractcontrolpoint(v, t) {
var range = 10;
var p = cps.shift();
pcount++;
data += p.key + ',' + p.value.lng().tofixed(6) + ',' + p.value.lat().tofixed(6) + ',' + ge.getglobe().getgroundaltitude(p.value.lat(), p.value.lng()).tofixed(3) + '\r\n';
if (cps.length > 0) {
movemaptopoint(cps[0].value, range, 6, null);
settimeout('extractcontrolpoint(' + v + ',' + t + ')', t);
} else {
window.external.extractcontrolpointsokcallback_(data, pcount);
data = '';
pcount = 0;
}
}
function getcontrolpointscount() {
cps = [];
var length = cpoints.length;
var p = null;
var n = 0;
for (var i = 0; i < length; i++) {
p = getobjectbyid(cpoints[i]);
if (p != null) {
cps.push({
key: p.getname(),
value: new geo.point(p.getgeometry().getlatitude(), p.getgeometry().getlongitude())
});
n++;
}
}
return n;
}
function extractpolyelevationsforcontour(d) {
d = parsefloat(d);
calpolypointsnum(d);
if (window.external.stopproduce(calpolypointsnumforcontour()) == '0') {
return;
}
var p = 20;
var v = 6;
var t = 5;
var range = 2 * d * p + 200;
if (extracttimes == 0) {
hheading = polyparams[0].heading(points[1]);
vheading = polyparams[0].heading(points[3]);
getrectanglepoints(ppoints[0], d, p);
ppoints[4] = 0;
ppoints[5] = 0;
}
movemaptopoint(getpointlocationbydha(ppoints[1], d * (p - 1), vheading), range, 5, null);
settimeout('extractpolyelevationforcontour(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ');', 2000);
}
function extractpolyelevationforcontour(d, p, range, v, t) {
var anum = polyparams[2];
var bnum = polyparams[3];
pcount = 0;
var xpoint = null;
var ypoint = null;
var mpoint = null;
var point = null;
var data = '';
var xyh = '';
var alts = [];
for (var i = ynum; i < bnum; i = i + 2 * p - 1) {
for (var j = xnum; j < anum; j = j + p) {
if (j == 0) {
qpoint = ppoints[3];
}
ypoint = ppoints[0];
for (var y = ppoints[4]; y <= 2 * (p - 1); y++) {
if (i + y + 1 > bnum) {
break;
}
xpoint = getpointlocationbydha(ypoint, d * y, vheading);
for (var x = ppoints[5]; x < p; x++) {
if (j + x + 1 > anum) {
break;
}
point = getpointlocationbydha(xpoint, d * x, hheading);
var coordinate = getpointbylatlng(point.lat(), point.lng());
if (!iscontainslatlng(pbounds, ppaths, coordinate)) {
continue;
}
pcount++;
var altitude = ge.getglobe().getgroundaltitude(point.lat(), point.lng()).tofixed(3);
alts.push(altitude);
data += point.lng().tofixed(6) + ' ' + point.lat().tofixed(6) + ' ' + altitude + '\r\n';
if (pcount % 100 == 0) {
window.external.waitetime(1);
window.external.returncontourpoints(data, '');
data = '';
}
}
ppoints[5] = 0;
}
ppoints[4] = 0;
xnum = 0;
getrectanglepoints(ppoints[1], d, p);
mpoint = getpointlocationbydha(ppoints[1], d * (p - 1), vheading);
movemaptopoint(mpoint, range, 5, null);
if (pcount == 0 || pcount % 100 != 0) {
window.external.waitetime(1);
}
sleep(t);
}
var altmin = alts.min();
var altmax = alts.max();
alts = [];
alts.push(altmin);
alts.push(altmax);
getrectanglepoints(getpointlocationbydha(qpoint, d, vheading), d, p);
mpoint = getpointlocationbydha(ppoints[1], d * (p - 1), vheading);
movemaptopoint(mpoint, range, 5, null);
if (pcount == 0 || pcount % 100 != 0) {
window.external.waitetime(1);
}
sleep(t);
}
ynum = 0;
movemaptopoint(polyparams[0], d * anum, 5, null);
window.external.getcontourelevationokcallback_(points[0].lng().tofixed(6) + ',' + points[2].lng().tofixed(6) + ',' + points[2].lat().tofixed(6) + ',' + points[0].lat().tofixed(6), math.floor(alts.min() / 10) * 10 + ',' + math.ceil(alts.max()), data, xyh);
data = '';
alts = [];
}
function calpolypointsnumforcontour() {
var area = polyparams[5];
var totalpointscount = polyparams[6];
var polygonarea = computeareaandc(polygoncontourobj);
return parseint(polygonarea[1] / area * totalpointscount);
}
function appendcontourkml(contourkml) {
importkmlfile_e(contourkml);
}
var profilelineobj = null;
var profilepaths = [];
function getpathidentify(obj) {
profilelineobj = null;
profilepaths = [];
var flag = '失败';
switch (obj.getgeometry().gettype()) {
case 'kmllinestring':
var coords = obj.getgeometry().getcoordinates();
var length = coords.getlength();
for (var i = 0; i < length; i++) {
profilepaths.push(new geo.point(coords.get(i)));
}
flag = '成功';
profilelineobj = obj;
break;
case 'kmlmultigeometry':
var geoms = obj.getgeometry().getgeometries();
for (var j = 0; j < geoms.getchildnodes().getlength(); j++) {
if (geoms.getchildnodes().item(j).gettype() == 'kmllinestring') {
var coords = geoms.getchildnodes().item(j).getcoordinates();
var length = coords.getlength();
for (var i = 0; i < length; i++) {
profilepaths.push(new geo.point(coords.get(i)));
}
}
}
flag = '成功';
profilelineobj = obj;
break;
default:
}
window.external.getpathobjectcallback_(flag);
}
function extractpointselevationsforprofile(d, p, range, v, t) {
var pacount = 0;
var dd = 0;
var d = 0;
var dh = 0;
var hd = 0;
var alt = 0;
var e = 0;
data = '[';
var ipoint = null;
var movepoint = null;
var heading = 0;
if (extracttimes == 0) {
pcount = 1;
extracttimes++;
alt = ge.getglobe().getgroundaltitude(profilepaths[0].lat(), profilepaths[0].lng()).tofixed(3);
data += returnprofilejson(0, alt);
}
var setpointsnum = profilepaths.length;
for (var i = 1; i < setpointsnum; i++) {
ipoint = profilepaths[i - 1];
heading = profilepaths[i - 1].heading(profilepaths[i]);
dh = gethorizontaldistance(profilepaths[i - 1], profilepaths[i]);
hd = dh.add(e);
dd = dd.add(dh);
for (var j = 1; j <= hd.div(d); j++) {
if (j == 1) {
ipoint = getpointlocationbydha(ipoint, d.sub(e), heading);
} else {
ipoint = getpointlocationbydha(ipoint, d, heading);
}
pcount++;
d = d.add(d);
alt = ge.getglobe().getgroundaltitude(ipoint.lat(), ipoint.lng()).tofixed(3);
data += returnprofilejson(d, alt);
if (pcount % p == 0) {
window.external.waitetime(50);
}
if ((pcount - 2) % p == 0) {
var hdd = 0;
hdd = hdd.add(gethorizontaldistance(ipoint, profilepaths[i]));
if (hdd >= p * d) {
movepoint = getpointlocationbydha(ipoint, p * d, ipoint.heading(profilepaths[i]));
} else {
hdd = (p * d).sub(hdd);
for (var k = i; k < 100000000000; k++) {
if (k < setpointsnum - 1) {
var dd = gethorizontaldistance(profilepaths[k], profilepaths[k + 1]);
if (hdd <= dd) {
movepoint = getpointlocationbydha(profilepaths[k], hdd, profilepaths[k].heading(profilepaths[k + 1]));
break;
} else {
hdd = hdd.sub(dd);
}
} else {
movepoint = profilepaths[setpointsnum - 1];
break;
}
}
}
heading = ipoint.heading(profilepaths[i]);
movemaptopoint(movepoint, range, v, null);
sleep(t);
}
}
e = hd % d;
pcount++;
alt = ge.getglobe().getgroundaltitude(profilepaths[i].lat(), profilepaths[i].lng()).tofixed(3);
data += returnprofilejson(d.add(gethorizontaldistance(ipoint, profilepaths[i])), alt);
}
data += returnprofilejson(dd, alt);
window.external.getprofileelevationokcallback_(data + ']', d.tofixed(2));
data = '';
}
function extractpathelevationsforprofile(d) {
if (profilelineobj == null) {
alert('请设置剖面路径!');
return;
}
d = parsefloat(d);
var p = 20;
var v = 6;
var t = 500;
var range = 2 * d * p + 20;
movemaptopoint(profilepaths[0], range, 5, null);
pcount = 0;
settimeout('extractpointselevationsforprofile(' + d + ',' + p + ',' + range + ',' + v + ',' + t + ');', 2000);
}
function returnprofilejson(d, alt) {
return '{d:"' + d + '",alt:"' + alt + '"},';
}
var profilepmobj = null;
function showprofileplacemark(d, alt) {
if (d < 0) {
return;
}
var point = getpointbydistancefrompath(d);
if (point != null) {
var name = '距离:' + (d / 1000).tofixed(2) + '千米\r\n海拔:' + alt + '米。';
if (profilepmobj == null) {
profilepmobj = drawpoint1(getuniqueid(), point, name, '');
} else {
profilepmobj.getgeometry().setlatitude(point.lat());
profilepmobj.getgeometry().setlongitude(point.lng());
profilepmobj.setname(name);
}
}
}
function getpointbydistancefrompath(d) {
var d = 0;
var point = null;
var pointsnum = profilepaths.length;
for (var i = 0; i < pointsnum - 1; i++) {
d = gethorizontaldistance(profilepaths[i], profilepaths[i + 1]);
d = parsefloat(d).sub(d);
if (d <= 0) {
point = getpointlocationbydha(profilepaths[i], d.add(d), profilepaths[i].heading(profilepaths[i + 1]));
break;
}
}
return point;
}
function disposeprofilepoints() {
profilepaths = [];
profilepmobj = null;
profilelineobj = null;
}
function getpolygonbounderystring() {
if (polygonboundery == null) {
return '';
}
var path = polygonboundery.getpath();
var length = path.length;
var pathstr = '';
for (var i = 0; i < length; i++) {
if (i > 0) {
pathstr += ';';
}
var pathi = path.getat(i);
pathstr += pathi.lat() + ',' + pathi.lng();
if (i == length - 1) {
pathstr += ';' + path.getat(0).lat() + ',' + path.getat(0).lng();
}
}
return pathstr;
}
function setrandompoints(n) {
var pbounds = polygonboundery.getbounds();
var ppaths = polygonboundery.getpaths();
var minlat = pbounds.getsouthwest().lat();
var maxlat = pbounds.getnortheast().lat();
var minlng = pbounds.getsouthwest().lng();
var maxlng = pbounds.getnortheast().lng();
var difflat = maxlat - minlat;
var difflng = maxlng - minlng;
for (var i = 0; i < n; i++) {
var lat = math.random() * difflat + minlat;
var lng = math.random() * difflng + minlng;
if (!iscontainslatlng(pbounds, ppaths, getpointbylatlng(lat, lng))) {
i--;
continue;
} else {
drawpoint(getuniqueid(), [lat, lng, 0], '点_' + i, '经度:' + lng + ',纬度:' + lat);
}
}
}
var cipolygon = null;
var cipoints = [];
function addrectangleonearth(latmin, latmax, lngmin, lngmax) {
cipoints[0] = new geo.point(latmax, lngmin);
cipoints[1] = new geo.point(latmax, lngmax);
cipoints[2] = new geo.point(latmin, lngmax);
cipoints[3] = new geo.point(latmin, lngmin);
try {
removeobject(cipolygon);
} catch (error) {}
cipolygon = null;
cipolygon = gex.dom.addpolygonplacemark(cipoints, {
id: getuniqueid(),
name: '影像下载',
description: '影像下载范围',
style: {
poly: {
color: 'white',
opacity: 0,
fill: false,
outline: true
},
line: pathstyle
}
});
}
var tcpoints = [];
var w = h = 256;
var xn = yn = 0;
function cutearthtiles(width, height) {
var centerx = width / 2;
var centery = height / 2;
var centerpoint1 = gethittestresult(centerx, centery);
movetopoint(centerpoint1, '');
tcpoints[0] = centerpoint1;
xn = yn = 0;
}
var mn = 0
function movextilewindow(width, height) {
var centerx = width / 2;
var centery = height / 2;
var centerpoint = new geo.point(gethittestresult(centerx, centery).lat(), gethittestresult(centerx + w / 2, centery).lng());
movetopoint(centerpoint, '');
if (mn == 0) {
mn++;
movextilewindow(width, height);
} else {
mn = 0;
settimeout('getscreenmap(' + xn + ',' + yn + ')', 100);
xn++;
}
}
function moveytilewindow(width, height) {
movetopoint(tcpoints[0], '');
var centerx = width / 2;
var centery = height / 2;
var centerpoint = new geo.point(gethittestresult(centerx, centery + h / 2).lat(), gethittestresult(centerx, centery).lng());
movetopoint(centerpoint, '');
tcpoints[0] = centerpoint;
if (mn == 0) {
mn++;
moveytilewindow(width, height);
} else {
mn = 0;
xn = 0;
yn++;
settimeout('getscreenmap(' + xn + ',' + yn + ')', 100);
}
}
function getscreencenter() {
var lookat = ge.getview().copyaslookat(ge.altitude_relative_to_ground);
var lat = lookat.getlatitude();
var lng = lookat.getlongitude();
return new geo.point(lat, lng);
}
function movetopoint(point, alt) {
var camera = ge.getview().copyascamera(ge.altitude_relative_to_ground);
camera.setlatitude(point.lat());
camera.setlongitude(point.lng());
camera.settilt(0);
camera.setroll(0);
camera.setheading(0);
if (alt != '' && alt > 0) {
camera.setaltitude(alt);
}
ge.getview().setabstractview(camera);
}
function gethittestresult(x, y) {
var hittestresult = ge.getview().hittest(x, ge.units_pixels, y, ge.units_pixels, ge.hit_test_globe);
return new geo.point(hittestresult.getlatitude(), hittestresult.getlongitude());
}
function addpoint(name, description, point) {
drawpoint(getuniqueid(), [point.lat(), point.lng(), 0], name, description);
}
function addtileanglepoint(centerx, centery) {
var ltpoint = gethittestresult(centerx - w / 2, centery - h / 2);
addpoint('左上', 'qqwewe', ltpoint);
var rtpoint = gethittestresult(centerx + w / 2, centery - h / 2);
addpoint('右上', 'qqwewe', rtpoint);
var rbpoint = gethittestresult(centerx + w / 2, centery + h / 2);
addpoint('右下', 'qqwewe', rbpoint);
var lbpoint = gethittestresult(centerx - w / 2, centery + h / 2);
addpoint('左下', 'qqwewe', lbpoint);
}
function getscreenmap(xn, yn) {
window.external.cutwindowimage(xn, yn);
}
function getcurrentearthcameraaltitude() {
var camera = ge.getview().copyascamera(ge.altitude_relative_to_ground);
var alt = parseint(camera.getaltitude());
if (alt < 200) {
alt = 200;
}
camera.setaltitude(alt);
ge.getview().setabstractview(camera);
return alt;
}
function setcurrentearthcameraaltitude(cameraalt) {
var camera = ge.getview().copyascamera(ge.altitude_relative_to_ground);
camera.setaltitude(cameraalt);
ge.getview().setabstractview(camera);
}
var colscount = rowscount = 0;
function calculateearthtiles(width, height, w, h, alt) {
alt = parseint(alt);
var cx = width / 2;
var cy = height / 2;
var lng0 = (cipoints[2].lng() + cipoints[3].lng()) / 2;
var lat0 = cipoints[2].lat();
var p0 = new geo.point(lat0, lng0);
movetopoint(p0, alt);
colscount = 2 * getcolstilescount(lat0, lng0, cipoints[2].lng(), alt, cx, cy, w);
movetopoint(p0, alt);
rowscount = getrowstilescount(lat0, lng0, cipoints[1].lat(), alt, cx, cy, h);
movetopoint(p0, alt);
var latc = getcenterlat(p0, alt, cx, cy - h / 2);
movetopoint(new geo.point(latc, lng0), alt);
var rb = getbounderyleftright(latc, alt, cx + w / 2, cy);
movetopoint(new geo.point(latc, lng0), alt);
var lb = getbounderyleftright(latc, alt, cx - w / 2, cy);
movetopoint(p0, alt);
var bb = getbounderytopbottom(p0, cx, cy + w / 2, alt);
var tcpoint = rpoints[rpoints.length - 1];
movetopoint(tcpoint, alt);
var tb = getbounderytopbottom(tcpoint, cx, cy - w / 2, alt);
movemaptopoint(new geo.point((cipoints[0].lat() + cipoints[3].lat()) / 2, (cipoints[0].lng() + cipoints[1].lng()) / 2), gethorizontaldistance(new geo.point(cipoints[0].lat(), cipoints[0].lng()), new geo.point(cipoints[2].lat(), cipoints[2].lng())), 6, null);
window.external.showcutearthtiles(rowscount * colscount, rowscount, colscount, tb.lng(), tb.lat(), bb.lng(), bb.lat(), lb.lng(), lb.lat(), rb.lng(), rb.lat(), gethorizontaldistance(lb, rb).tofixed(0), gethorizontaldistance(tb, bb).tofixed(0));
}
function getcenterlat(p0, alt, cx, y) {
var lng = p0.lng();
var n = 1;
var p = tp = null;
while (n < rowscount) {
tp = gethittestresult(cx, y);
p = new geo.point(tp.lat(), lng);
movetopoint(p, alt);
n++;
}
return p.lat();
}
function getbounderytopbottom(p, cx, y, alt) {
var tp = gethittestresult(cx, y);
var point = new geo.point(tp.lat(), p.lng());
return point;
}
function getbounderyleftright(lat, alt, x, cy) {
var n = 1;
var p = tp = null;
while (n <= colscount) {
tp = gethittestresult(x, cy);
p = new geo.point(lat, tp.lng());
movetopoint(p, alt);
n++;
}
return p;
}
function getcolstilescount(lat, lng, bounderylng, alt, cx, cy, w) {
var p = tp = null;
var n = k = 0;
var x = cx + w / 2;
p = new geo.point(lat, lng);
while (lng <= bounderylng) {
if (n % 2 != 0) {
k++;
}
n++;
tp = gethittestresult(x, cy);
p = new geo.point(lat, tp.lng());
movetopoint(p, alt);
lng = p.lng();
}
if (n % 2 != 0) {
return k + 1;
}
return k;
}
var rpoints = [];
function getrowstilescount(lat, lng, bounderylat, alt, cx, cy, h) {
var p = tp = null;
rpoints = [];
var n = k = 1;
var y = cy - h / 2;
p = new geo.point(lat, lng);
while (lat <= bounderylat) {
if (n % 2 != 0) {
rpoints.push(p);
k++;
}
n++;
tp = gethittestresult(cx, y);
p = new geo.point(tp.lat(), lng);
movetopoint(p, alt);
lat = p.lat();
}
p = rpoints[rpoints.length - 1];
movetopoint(p, alt);
tp = gethittestresult(cx, y);
p = new geo.point(tp.lat(), lng);
if (p.lat() <= bounderylat) {
movetopoint(p, alt);
tp = gethittestresult(cx, y);
p = new geo.point(tp.lat(), lng);
rpoints.push(p);
movetopoint(p, alt);
return k;
}
return k - 1;
}
var t = 0;
function starttocutearthtiles(width, height, w, alt, delaytime) {
alt = parseint(alt);
delay = parseint(delaytime);
var cx = width / 2;
var cy = height / 2;
var x = cx + w / 2;
var lng0 = (cipoints[2].lng() + cipoints[3].lng()) / 2;
var lat0 = cipoints[2].lat();
var p0 = new geo.point(lat0, lng0);
movetopoint(p0, alt);
xn = 1;
yn = 0;
t = 0;
redycuttile(width, height, w, x, cy, alt, delay);
}
function redycuttile(width, height, w, x, cy, alt, delay) {
if (xn == 1 && yn == 0 && w > 0) {
etcount = 0;
}
var p = rpoints[t];
t++;
movetopoint(p, alt);
var tp = gethittestresult(x, cy);
cp = new geo.point(p.lat(), tp.lng());
movetopoint(cp, alt);
settimeout('begintocuttile(' + width + ',' + height + ',' + w + ',' + x + ',' + cy + ',' + alt + ',' + delay + ')', delay);
}
var cp = null;
var etcount = 0;
function begintocuttile(width, height, w, x, cy, alt, delay) {
if (waitprocessrun == true) {
waitprocessrun = false;
return;
}
getscreenmap((w <= 0) ? -xn : xn, yn);
etcount++;
window.external.cutingearthtilescallback(etcount);
if (pagestoprunflag == true) {
pagestoprunflag = false;
return;
}
if (xn < colscount / 2) {
xn++;
} else {
xn = 1;
yn++;
if (yn >= rowscount) {
yn = 0;
if (w <= 0) {
movemaptopoint(new geo.point((cipoints[0].lat() + cipoints[3].lat()) / 2, (cipoints[0].lng() + cipoints[1].lng()) / 2), gethorizontaldistance(new geo.point(cipoints[0].lat(), cipoints[0].lng()), new geo.point(cipoints[2].lat(), cipoints[2].lng())), 6, null);
window.external.cutearthtilesok();
return;
}
starttocutearthtiles(width, height, -w, alt, delay);
return;
}
redycuttile(width, height, w, x, cy, alt, delay);
return;
}
var tp = gethittestresult(x, cy);
var p = new geo.point(cp.lat(), tp.lng());
movetopoint(p, alt);
tp = gethittestresult(x, cy);
p = new geo.point(p.lat(), tp.lng());
movetopoint(p, alt);
cp = p;
settimeout('begintocuttile(' + width + ',' + height + ',' + w + ',' + x + ',' + cy + ',' + alt + ',' + delay + ')', parseint(window.external.getcutearthtiledelaytime()));
}
var waitprocessrun = false;
function waitprocessrun() {
waitprocessrun = true;
}
function continuewebbrowserrun(width, height, w, alt, delay) {
begintocuttile(width, height, w, width / 2 + w / 2, height / 2, alt, delay);
}
function slicecutearthmap(tlat, blat, llng, rlng, rowscount, colscount) {
var difflat = tlat - blat;
var difflng = rlng - llng;
var latmax, latmin, lngmin, lngmax;
if (rowscount > 1) {
removeslicemaps();
var dlat = difflat / rowscount;
var dlng = difflng / colscount;
for (var i = 0; i < rowscount; i++) {
for (var j = 0; j < colscount; j++) {
latmax = tlat - i * dlat;
latmin = tlat - (i + 1) * dlat;
lngmin = llng + j * dlng;
lngmax = llng + (j + 1) * dlng
addslicemap(latmin, latmax, lngmin, lngmax);
}
}
}
}
var slicemappoints = [];
function addslicemap(latmin, latmax, lngmin, lngmax) {
var ps = [];
ps[0] = new geo.point(latmax, lngmin);
ps[1] = new geo.point(latmax, lngmax);
ps[2] = new geo.point(latmin, lngmax);
ps[3] = new geo.point(latmin, lngmin);
var id = getuniqueid();
slicemappoints.push(id);
gex.dom.addpolygonplacemark(ps, {
id: id,
name: '影像下载',
description: '影像下载范围',
style: {
poly: {
color: 'white',
opacity: 0,
fill: false,
outline: true
},
line: {
width: 1,
opacity: 1,
color: '#ffffff'
}
}
});
}
function removeslicemaps() {
var length = slicemappoints.length;
for (var i = 0; i < length; i++) {
removeobject(getobjectbyid(slicemappoints.shift()));
}
}
function removedemregin(id) {
removeobject(getobjectbyid(demrectangleids[id]));
var length = demrectangleids.length;
var k = 0;
var dems = demrectangleids;
demrectangleids = [];
for (var i = 0; i < length; i++) {
if (i != id) {
demrectangleids[k] = dems[i];
k++;
}
}
}
function clearalldemregin() {
var length = demrectangleids.length;
for (var i = 0; i < length; i++) {
removeobject(getobjectbyid(demrectangleids.shift()));
}
}
var demrectangleids = [];
function adddemreginonearth(blat, tlat, llng, rlng) {
var ps = [];
ps[0] = new geo.point(parsefloat(tlat), parsefloat(llng));
ps[1] = new geo.point(parsefloat(tlat), parsefloat(rlng));
ps[2] = new geo.point(parsefloat(blat), parsefloat(rlng));
ps[3] = new geo.point(parsefloat(blat), parsefloat(llng));
var id = getuniqueid();
demrectangleids.push(id);
gex.dom.addpolygonplacemark(ps, {
id: id,
name: 'dem',
description: 'dem',
style: {
poly: {
color: 'red',
opacity: 0,
fill: false,
outline: true
},
line: {
width: 1,
opacity: 1,
color: '#ffffff'
}
}
});
}
function selectobjecttoidentify_m(key, m) {
alert('提取高程信息需切换到谷歌地球三维模式!');
}
var trafficlayer = null;
var bikelayer = null;
var weatherlayer = null;
var cloudlayer = null;
function setmapzoom(zoom) {
gotolocationbypoint(map.getcenter(), parseint(zoom));
}
function setmaplookat(zoom) {
var point;
if (downloadimagepath != null) {
point = downloadimagepath.getpath().getat(0);
} else {
point = map.getcenter();
}
gotolocationbypoint(point, parseint(zoom));
}
function setmapstatus(s1, s2, s3, s4) {
if (s1 == true) {
trafficlayer = new google.maps.trafficlayer();
trafficlayer.setmap(map);
} else {
trafficlayer.setmap(null);
}
if (s2 == true) {
bikelayer = new google.maps.bicyclinglayer();
bikelayer.setmap(map);
} else {
bikelayer.setmap(null);
}
if (s3 == true) {
weatherlayer = new google.maps.weather.weatherlayer({
temperatureunits: google.maps.weather.temperatureunit.celcius
});
weatherlayer.setmap(map);
} else {
weatherlayer.setmap(null);
}
if (s4 == true) {
cloudlayer = new google.maps.weather.cloudlayer();
cloudlayer.setmap(map);
} else {
cloudlayer.setmap(null);
}
}
var markersarray = [];
var infowindowarray = [];
var rubbishobject_m = [];
function getmysatellitetileaddress(lng, lat, digits) {
var pi = 3.1415926535897;
var x = (180.0 + parsefloat(lng)) / 360.0;
var y = -parsefloat(lat) * pi / 180;
y = 0.5 * math.log((1 + math.sin(y)) / (1 - math.sin(y)));
y *= 1.0 / (2 * pi);
y += 0.5;
var quad = "t";
var lookup = "qrts";
while (digits--) {
x -= math.floor(x);
y -= math.floor(y);
quad = quad + '/' + lookup.substr((x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0), 1);
x *= 2;
y *= 2;
}
return quad;
}
function tile2long(x, z) {
return (x / math.pow(2, z) * 360 - 180);
}
function tile2lat(y, z) {
var n = math.pi - 2 * math.pi * y / math.pow(2, z);
return (180 / math.pi * math.atan(0.5 * (math.exp(n) - math.exp(-n))));
}
function getquadtreeaddress(lng, lat, digits) {
var pi = 3.1415926535897;
var x = (180.0 + parsefloat(lng)) / 360.0;
var y = -parsefloat(lat) * pi / 180;
y = 0.5 * math.log((1 + math.sin(y)) / (1 - math.sin(y)));
y *= 1.0 / (2 * pi);
y += 0.5;
var quad = "t";
var lookup = "qrts";
while (digits--) {
x -= math.floor(x);
y -= math.floor(y);
quad = quad + lookup.substr((x >= 0.5 ? 1 : 0) + (y >= 0.5 ? 2 : 0), 1);
x *= 2;
y *= 2;
}
return quad;
}
function searchlatlngbylocation_m(a) {
$.getjson('http://maps.googleapis.com/maps/api/geocode/json?address=' + a + '&sensor=false', function (json) {
if (json['status'] == 'ok') {
var mylatlng = new google.maps.latlng(json['results'][0]['geometry']['location']['lat'], json['results'][0]['geometry']['location']['lng']);
searchlocation_m(mylatlng.lat(), mylatlng.lng());
}
});
}
function gotolocationbypoint(mylatlng, zoom) {
map.setcenter(mylatlng);
map.setzoom(zoom);
}
function drawmarker(mylatlng) {
var marker = new google.maps.marker({
icon: iconurl,
position: mylatlng,
map: map,
title: "i am here!"
});
addmarkerersarray('marker', marker);
var markerinfo = new nameoverlay(mylatlng, marker.gettitle(), map);
addmarkerersarray('markerinfo', markerinfo);
google.maps.event.addlistener(marker, "click", function () {
if (dowhat_m == 1) {
removeobjectbyclick(this);
if (markerinfo != null) {
removeobjectbyclick(markerinfo);
}
} else if (dowhat_m == 2) {
if (markerinfo != null) {
editmarker(this, markerinfo);
}
}
});
}
function searchlocation_m(lat, lng) {
var mylatlng = new google.maps.latlng(lat, lng);
gotolocationbypoint(mylatlng, 10);
drawmarker(mylatlng);
}
function importkmlfile_m(kmlstring) {
var flag = 1;
var xmldoc2 = new activexobject('microsoft.xmldom');
xmldoc2.async = 'false';
xmldoc2.loadxml(kmlstring);
var docroot = xmldoc2.documentelement;
var pms = docroot.selectnodes('//placemark');
var pmslength = pms.length;
var coords = [];
try {
for (var i = 0; i < pmslength; i++) {
var pm = pms[i];
var name = (pm.selectsinglenode('name')) ? pm.selectsinglenode('name').text.trim() : '';
var type = '';
if (pm.selectsinglenode('point')) {
type = 'point';
var description = (pm.selectsinglenode('description')) ? pm.selectsinglenode('description').text.trim() : '描述';
iconurl = (pm.selectsinglenode('style/iconstyle/icon/href')) ? pm.selectsinglenode('style/iconstyle/icon/href').text : 'http://www.goodygis.com/earth/icons/ylw-pushpin.png';
var coordinates = (pm.selectsinglenode('point')) ? pm.selectsinglenode('point/coordinates').text.trim() : '';
if (coordinates != '') {
coords = coordinates.split(',');
addmarker(name, getpointbylatlng(coords[1], coords[0]), description);
} else {
flag = 0;
}
} else if (pm.selectsinglenode('linestring')) {
type = 'line';
var coordinates = (pm.selectsinglenode('linestring')) ? pm.selectsinglenode('linestring//coordinates').text.trim() : '';
if (coordinates != '') {
var coordss = coordinates.replace(/\n/g, ' ').replace(/\s+/g, ' ').split(' ');
var coordsslength = coordss.length;
var linecoords = [];
for (var j = 0; j < coordsslength; j++) {
coords = coordss[j].split(',');
linecoords.push(getpointbylatlng(coords[1], coords[0]));
}
addline(name, linecoords);
} else {
flag = 0;
}
} else if (pm.selectsinglenode('polygon')) {
type = 'polygon';
var coordinates = (pm.selectsinglenode('polygon')) ? pm.selectsinglenode('polygon//coordinates').text.trim() : '';
if (coordinates != '') {
var coordss = coordinates.replace(/\n/g, ' ').replace(/\s+/g, ' ').split(' ');
var coordsslength = coordss.length;
var polygoncoords = [];
for (var j = 0; j < coordsslength; j++) {
coords = coordss[j].split(',');
polygoncoords.push(getpointbylatlng(coords[1], coords[0]));
}
addpolygon(name, polygoncoords);
} else {
flag = 0;
}
} else if (pm.selectsinglenode('multigeometry')) {
type = 'multigeometry';
var linestrings = pm.selectnodes('multigeometry//linestring') ? pm.selectnodes('multigeometry//linestring') : '';
var linelength = linestrings.length;
if (linelength > 0) {
for (var x = 0; x < linelength; x++) {
var coordinates = linestrings[x].selectsinglenode('coordinates').text.trim();
var coordss = coordinates.replace(/\n/g, ' ').replace(/\s+/g, ' ').split(' ');
var coordsslength = coordss.length;
var linecoords = [];
for (var j = 0; j < coordsslength; j++) {
coords = coordss[j].split(',');
linecoords.push(getpointbylatlng(coords[1], coords[0]));
}
addline(name, linecoords);
}
} else {
flag = 0;
}
} else {
flag = 0;
alert('提示:系统未识别该图形,目前只能导入点、线和面图形!');
}
}
gotolocationbypoint(getpointbylatlng(coords[1], coords[0]), 15);
} catch (err) {
flag = 0;
}
docroot = null;
xmldoc2 = null;
kmlstring = '';
return flag;
}
function getgekml_m() {
var kmlstring = '';
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
var obj = markersarray[i];
if (obj.key == 'marker') {
var markerlatlng = obj.value.position;
var description = getinfowindowcontent(markerlatlng);
kmlstring += ' <placemark>\r\n' + ' <name>' + ((obj.value.title == 'undefined' || obj.value.title == null) ? '地标' : obj.value.title) + '</name>\r\n' + ' <description>' + ((description == '') ? '描述' : description) + '</description>\r\n' + ' <style><iconstyle><icon><href>' + ((obj.value.geticon() == 'undefined' || obj.value.geticon() == null) ? 'http://www.goodygis.com/earth/icons/ylw-pushpin.png' : obj.value.geticon()) + '</href></icon></iconstyle></style>\r\n';
kmlstring += ' <point><coordinates>' + markerlatlng.lng() + ',' + markerlatlng.lat() + ',0</coordinates></point>\r\n';
kmlstring += ' </placemark>\r\n';
} else if (obj.key == 'line') {
kmlstring += ' <placemark>\r\n' + ' <name>' + ((obj.value.title == 'undefined' || obj.value.title == null) ? '路线' : obj.value.title) + '</name>\r\n';
kmlstring += ' <style><linestyle><color>' + mergecoloropacity(obj.value.strokecolor, obj.value.strokeopacity) + '</color><width>' + obj.value.strokeweight + '</width></linestyle></style>\r\n';
var linecoords = obj.value.getpath();
var linecoordsstr = '';
for (var j = 0; j < linecoords.length; j++) {
linecoordsstr += linecoords.getat(j).lng() + ',' + linecoords.getat(j).lat() + ',0 ';
}
kmlstring += ' <linestring>\r\n' + ' <tessellate>1</tessellate>\r\n' + ' <coordinates>' + linecoordsstr + '</coordinates>\r\n' + ' </linestring>\r\n';
kmlstring += ' </placemark>\r\n';
} else if (obj.key == 'polygon') {
kmlstring += ' <placemark>\r\n' + ' <name>' + ((obj.value.title == 'undefined' || obj.value.title == null) ? '多边形' : obj.value.title) + '</name>\r\n';
kmlstring += ' <style><linestyle><color>' + mergecoloropacity(obj.value.strokecolor, obj.value.strokeopacity) + '</color><width>' + (obj.value.strokeweight + 1) + '</width></linestyle><polystyle><color>' + mergecoloropacity(obj.value.fillcolor, obj.value.fillopacity) + '</color><fill>1</fill><outline>1</outline></polystyle></style>\r\n';
var polygoncoords = obj.value.getpath();
var polygoncoordsstr = '';
for (var j = 0; j < polygoncoords.length; j++) {
polygoncoordsstr += polygoncoords.getat(j).lng() + ',' + polygoncoords.getat(j).lat() + ',0 ';
if (j == polygoncoords.length - 1 && polygoncoords.getat(j).lng() != polygoncoords.getat(0).lng() && polygoncoords.getat(j).lat() != polygoncoords.getat(0).lat()) {
polygoncoordsstr += polygoncoords.getat(0).lng() + ',' + polygoncoords.getat(0).lat() + ',0';
}
}
kmlstring += ' <polygon>\r\n' + ' <tessellate>1</tessellate>\r\n' + ' <outerboundaryis>\r\n' + ' <linearring>\r\n' + ' <coordinates>' + polygoncoordsstr + '</coordinates>\r\n' + ' </linearring>\r\n' + ' </outerboundaryis>\r\n' + ' </polygon>\r\n';
kmlstring += ' </placemark>\r\n';
} else if (obj.key == 'retangle') {
kmlstring += ' <placemark>\r\n' + ' <name>' + ((obj.value.title == 'undefined' || obj.value.title == null) ? '矩形' : obj.value.title) + '</name>\r\n';
kmlstring += ' <style><linestyle><color>' + mergecoloropacity(obj.value.strokecolor, obj.value.strokeopacity) + '</color><width>' + (obj.value.strokeweight + 1) + '</width></linestyle><polystyle><color>' + mergecoloropacity(obj.value.fillcolor, obj.value.fillopacity) + '</color><fill>1</fill><outline>1</outline></polystyle></style>\r\n';
var polygoncoords = obj.value.getbounds();
var polygoncoordsstr = polygoncoords.getsouthwest().lng() + ',' + polygoncoords.getsouthwest().lat() + ',0 ' + polygoncoords.getsouthwest().lng() + ',' + polygoncoords.getnortheast().lat() + ',0 ' + polygoncoords.getnortheast().lng() + ',' + polygoncoords.getnortheast().lat() + ',0 ' + polygoncoords.getnortheast().lng() + ',' + polygoncoords.getsouthwest().lat() + ',0 ' + polygoncoords.getsouthwest().lng() + ',' + polygoncoords.getsouthwest().lat() + ',0';
kmlstring += ' <polygon>\r\n' + ' <tessellate>1</tessellate>\r\n' + ' <outerboundaryis>\r\n' + ' <linearring>\r\n' + ' <coordinates>' + polygoncoordsstr + '</coordinates>\r\n' + ' </linearring>\r\n' + ' </outerboundaryis>\r\n' + ' </polygon>\r\n';
kmlstring += ' </placemark>\r\n';
} else if (obj.key == 'circle') {
alert('本系统暂时不能导出圆!');
continue;
kmlstring += ' <placemark>\r\n' + ' <name>' + ((obj.value.title == 'undefined' || obj.value.title == null) ? '圆' : obj.value.title) + '</name>\r\n';
var polygoncoords = obj.value.getpath();
var polygoncoordsstr = '';
for (var j = 0; j < polygoncoords.length; j++) {
polygoncoordsstr += polygoncoords.getat(j).lng() + ',' + polygoncoords.getat(j).lat() + ',0 ';
}
kmlstring += ' <polygon>\r\n' + ' <tessellate>1</tessellate>\r\n' + ' <outerboundaryis>\r\n' + ' <linearring>\r\n' + ' <coordinates>' + polygoncoordsstr + '</coordinates>\r\n' + ' </linearring>\r\n' + ' </outerboundaryis>\r\n' + ' </polygon>\r\n';
kmlstring += ' </placemark>\r\n';
}
}
if (kmlstring != '') {
kmlstring = '<?xml version="1.0" encoding="utf-8"?>\r\n<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/atom">\r\n<document>\r\n' + kmlstring;
kmlstring += ' </document>\r\n' + '</kml>';
kmlstring = formatkmlforhtml(kmlstring);
}
}
return kmlstring;
}
function getpointbycoord(coord) {
return new google.maps.latlng(coord);
}
function getpointbylatlng(lat, lng) {
return new google.maps.latlng(lat, lng);
}
function addmarker(title, markercoord, description) {
var marker = new google.maps.marker({
icon: iconurl,
position: markercoord,
title: title,
draggable: false,
map: map
});
var markerinfo = new nameoverlay(markercoord, marker.gettitle(), map);
addmarkerersarray('marker', marker);
addmarkerersarray('markerinfo', markerinfo);
var infowindow = new google.maps.infowindow({
content: description
});
addinfowindowarray(markercoord.lat() + "|" + markercoord.lng(), infowindow);
google.maps.event.addlistener(marker, "click", function () {
if (dowhat_m == 0) {
infowindow.open(map, marker);
} else if (dowhat_m == 1) {
removeobjectbyclick(this);
if (markerinfo != null) {
removeobjectbyclick(markerinfo);
}
} else if (dowhat_m == 2) {
if (markerinfo != null) {
editmarker(this, markerinfo);
}
}
});
}
function removeobjectbyclick(obj) {
obj.setmap(null);
dowhat_m = 0;
removeobjectfromarray(obj);
window.external.setmousemovemsgbyweb('', false);
}
function addline(title, linecoords) {
var path = new google.maps.polyline({
title: title,
path: linecoords,
strokecolor: "#ff0000",
strokeopacity: 1.0,
strokeweight: 2,
map: map
});
addmarkerersarray('line', path);
google.maps.event.addlistener(path, "click", function () {
if (dowhat_m == 0) {
getpathinfos(this);
} else if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectlength(this);
}
});
}
function addpolygon(title, polygoncoords) {
var polygon = new google.maps.polygon({
title: title,
paths: polygoncoords,
strokecolor: "#ff0000",
strokeopacity: 0.8,
strokeweight: 2,
fillcolor: "#ff0000",
fillopacity: 0.1,
map: map
});
addmarkerersarray('polygon', polygon);
google.maps.event.addlistener(polygon, "click", function () {
if (dowhat_m == 0) {
showpolygonbox(this);
} else if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectareac(this);
}
});
}
function addmarkerersarray(type, m) {
markersarray.push({
key: type,
value: m
});
}
function clearoverlays() {
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
markersarray[i].value.setmap(null);
}
}
}
function addinfowindowarray(key, obj) {
infowindowarray.push({
key: key,
value: obj
});
}
function getinfowindowcontent(markerlatlng) {
var content = '';
if (infowindowarray) {
var keystr = markerlatlng.lat() + '|' + markerlatlng.lng();
for (var i = 0; i < infowindowarray.length; i++) {
if (infowindowarray[i].key == keystr) {
content = infowindowarray[i].value.getcontent();
break;
}
}
}
return content;
}
function setmarkerinfowindowcontent(markerlatlng, content) {
if (infowindowarray) {
var keystr = markerlatlng.lat() + '|' + markerlatlng.lng();
for (var i = 0; i < infowindowarray.length; i++) {
if (infowindowarray[i].key == keystr) {
content = infowindowarray[i].value.setcontent(content);
break;
}
}
}
}
function showoverlays() {
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
markersarray[i].value.setmap(map);
}
}
}
function deleteoverlays() {
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
markersarray[i].value.setmap(null);
}
markersarray.length = 0;
}
polygonbox = null;
}
function clearallobjs_m() {
deleteoverlays();
enddrawonefig();
}
function removeobjectfromarray(obj) {
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
if (markersarray[i].value == obj) {
markersarray.splice(i, 1);
return;
}
}
}
}
function modifymarkerersarray(obj, nobj) {
if (markersarray) {
for (var i = 0; i < markersarray.length; i++) {
if (markersarray[i].value == obj) {
obj.setmap(null);
markersarray[i].value = nobj;
return;
}
}
}
}
var figtype_m = '';
function drawfigure_m(figuretype) {
dowhat_m = 0;
if (figuretype != 'point' || (figuretype == 'point' && figtype_m != figuretype)) {
enddrawonefig();
}
figtype_m = figuretype;
}
function chushihuadrawfig_m() {
enddrawonefig();
}
var cases_m = {
'point': drawpointfunc_m,
'line': drawlinefunc_m,
'rectangle': drawretanglefunc_m,
'polygon': drawpolygonfunc_m
};
function addeventlistenerdrawfig_m() {
try {
google.maps.event.clearlisteners(map, 'rightclick', clickmousefunction);
google.maps.event.addlistener(map, 'rightclick', clickmousefunction);
} catch (err) {
}
}
function removeeventlistenerdrawfig_m() {
if (figtype_m != 'point') {
chushihuadrawfig_m();
}
figtype_m = '';
try {
google.maps.event.clearlisteners(map, 'rightclick', clickmousefunction);
dowhat_m = 0;
} catch (e) {
}
}
var dowhat_m = 0;
var clickmousefunction = function (event) {
if (dowhat_m == 0) {
if (cases_m[figtype_m]) {
cases_m[figtype_m](event);
}
}
}
function drawpointfunc_m(event) {
addmarker(markertitle, event.latlng, '描述');
var latlng = map.getcenter();
var textoverlay = new textoverlay(latlng, "<span style=\"color:#ff0000; width:auto;\">我爱你aaaaaaaaaaaaaaaaaaa!</span>");
map.addoverlay(textoverlay);
}
var line = null;
function drawlinefunc_m(event) {
if (line == null) {
line = new google.maps.polyline({
editable: true,
strokecolor: '#ff0000',
strokeopacity: 1.0,
strokeweight: 3,
map: map
});
addmarkerersarray('line', line);
google.maps.event.addlistener(line, "click", function () {
if (dowhat_m == 0) {
getpathinfos(this);
} else if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectlength(this);
}
});
}
line.getpath().push(event.latlng);
}
var retangle = null;
function drawretanglefunc_m(event) {
if (retangle == null) {
var retanglecap = new google.maps.marker({
position: event.latlng,
title: '端点',
map: map,
visible: false
});
rubbishobject_m.push(retanglecap);
retangle = new google.maps.rectangle({
clickable: true,
editable: true,
strokecolor: '#0000ff',
strokeopacity: 1.0,
strokeweight: 3,
fillopacity: 0.1,
map: map
});
addmarkerersarray('retangle', retangle);
google.maps.event.addlistener(retangle, "mousedown", function () {
if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 0) {
getretanglebounds(this);
} else if (dowhat_m == 3) {
measureretangleareac(this);
}
});
google.maps.event.addlistener(retangle, "bounds_changed", function () {
if (dowhat_m == 0) {
getretanglebounds(this);
}
});
}
var p1latlng = rubbishobject_m[rubbishobject_m.length - 1].getposition();
var maxlat = [event.latlng.lat(), p1latlng.lat()].max();
var minlat = [event.latlng.lat(), p1latlng.lat()].min();
var maxlng = [event.latlng.lng(), p1latlng.lng()].max();
var minlng = [event.latlng.lng(), p1latlng.lng()].min();
retangle.setbounds(new google.maps.latlngbounds(getpointbylatlng(maxlat, minlng), getpointbylatlng(minlat, maxlng)));
}
function getretanglebounds(obj) {
var bounds = obj.getbounds();
var maxlat = [bounds.getsouthwest().lat(), bounds.getnortheast().lat()].max();
var minlat = [bounds.getsouthwest().lat(), bounds.getnortheast().lat()].min();
var maxlng = [bounds.getsouthwest().lng(), bounds.getnortheast().lng()].max();
var minlng = [bounds.getsouthwest().lng(), bounds.getnortheast().lng()].min();
var pathstr = maxlat + ',' + minlng + ';' + maxlat + ',' + maxlng + ';' + minlat + ',' + maxlng + ';' + minlat + ',' + minlng;
window.external.setmapboundscallback_(maxlat, minlat, minlng, maxlng, pathstr);
}
var polygon = null;
function drawpolygonfunc_m(event) {
if (polygon == null) {
polygon = new google.maps.polygon({
clickable: true,
editable: true,
strokecolor: "#ff0000",
strokeopacity: 0.8,
strokeweight: 2,
fillcolor: "#ff0000",
fillopacity: 0.1,
map: map
});
addmarkerersarray('polygon', polygon);
google.maps.event.addlistener(polygon, "click", function () {
if (dowhat_m == 0) {
showpolygonbox(this);
} else if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectareac(this);
}
});
}
polygon.getpath().push(event.latlng);
}
var polygonbox = null;
function showpolygonbox(obj) {
var path = obj.getpath();
var length = path.length;
var lngtmp, lattmp, pathstr = '';
var minlng = maxlng = path.getat(0).lng();
var minlat = maxlat = path.getat(0).lat();
var pathstr = minlat + ',' + minlng;
for (var i = 1; i < length; i++) {
var pathi = path.getat(i);
pathstr += ';' + pathi.lat() + ',' + pathi.lng();
lngtmp = pathi.lng();
minlng = (lngtmp < minlng) ? lngtmp : minlng;
maxlng = (lngtmp > maxlng) ? lngtmp : maxlng;
lattmp = pathi.lat();
minlat = (lattmp < minlat) ? lattmp : minlat;
maxlat = (lattmp > maxlat) ? lattmp : maxlat;
}
var bounds = new google.maps.latlngbounds(new google.maps.latlng(minlat, minlng), new google.maps.latlng(maxlat, maxlng));
if (polygonbox != null) {
polygonbox.setbounds(bounds);
} else {
polygonbox = new google.maps.rectangle({
clickable: true,
editable: true,
strokecolor: '#0000ff',
strokeopacity: 1.0,
strokeweight: 3,
fillopacity: 0.35,
map: map,
bounds: bounds
});
google.maps.event.addlistener(polygonbox, "click", function () {
if (dowhat_m == 1) {
polygonbox = null;
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectareac(this);
}
});
google.maps.event.addlistener(polygonbox, "bounds_changed", function () {
if (dowhat_m == 0) {
getretanglebounds(this);
}
});
addmarkerersarray('retangle', polygonbox);
}
window.external.setmapboundscallback_(maxlat, minlat, minlng, maxlng, pathstr);
}
function getmapzoom() {
return map.getzoom();
}
function removeeventlistenerdrawfig_m() {
figtype_m = '';
try {
dowhat_m = 0;
enddrawonefig();
google.maps.event.clearlisteners(map, 'rightclick', clickmousefunction);
} catch (e) {
alert("请等待加载地图!");
}
}
function enddrawonefig() {
if (line != null) {
line.seteditable(false);
line = null;
}
if (retangle != null) {
retangle.seteditable(false);
retangle = null;
}
if (polygon != null) {
polygon.seteditable(false);
if (polygon.getpath().length < 3) {
polygon.setmap(null);
}
polygon = null;
}
if (rubbishobject_m.length > 0) {
for (var i = 0; i < rubbishobject_m.length; i++) {
rubbishobject_m[i].setmap(null);
}
rubbishobject_m = [];
}
}
function cancellinelaststep_m() {
if (line != null) {
line.getpath().pop();
if (line.getpath().length < 2) {
line.setmap(null);
line = null;
}
}
if (polygon != null) {
polygon.getpath().pop();
if (polygon.getpath().length < 3) {
polygon.setmap(null);
polygon = null;
}
}
}
function addeventlistenersetcircleparams_m(textbox) {
try {
google.maps.event.addlistener(map, 'mousemove', movemousegetcoords_m);
google.maps.event.addlistener(map, 'rightclick', clickrightmousegetcoords_m);
} catch (e) {
alert("请等待加载地图!");
}
activetextbox = textbox;
}
function removeeventlistenersetcircleparams_m() {
try {
google.maps.event.clearlisteners(map, 'mousemove', movemousegetcoords_m);
getmousecoordinates();
} catch (e) {
alert("请等待加载地图!");
}
activetextbox = '';
}
var movemousegetcoords_m = function (event) {
var param = '';
switch (activetextbox) {
case 'textbox1':
centerpointname = '圆心';
param = event.latlng.lng().tofixed(6) + ',' + event.latlng.lat().tofixed(6);
break;
case 'textbox2':
centerpointname = '半径';
var centerpoint = (window.external.gettextboxvalue('textbox1')).split(',');
if (centerpoint != '') {
try {
param = google.maps.geometry.spherical.computedistancebetween(getpointbylatlng(parsefloat(centerpoint[1]), parsefloat(centerpoint[0])), getpointbylatlng(event.latlng.lat(), event.latlng.lng())).tofixed(2);
} catch (err) {
try {
param = new geo.point(parsefloat(centerpoint[1]), parsefloat(centerpoint[0])).distance(new geo.point(event.latlng.lat(), event.latlng.lng())).tofixed(2);
} catch (errr) {}
}
} else {
activetextbox = 'textbox6';
}
break;
case 'textbox3':
break;
case 'textbox4':
break;
case 'textbox14':
centerpointname = '源点';
param = event.latlng.lng() + ',' + event.latlng.lat();
break;
case 'textbox15':
centerpointname = '目标点';
param = event.latlng.lng() + ',' + event.latlng.lat();
break;
default:
}
window.external.inputtextboxcoordscallback_(activetextbox, param);
}
var circlecenter = null;
var circleradius = null;
var originalpoint = null;
var targetpoint = null;
var clickrightmousegetcoords_m = function (event) {
removeeventlistenersetcircleparams_m();
if (centerpointname == '圆心') {
if (circlecenter != null) {
circlecenter.setmap(null);
}
circlecenter = new google.maps.marker({
position: event.latlng,
title: centerpointname,
map: map
});
rubbishobject_m.push(circlecenter);
} else if (centerpointname == '半径') {
if (circleradius != null) {
circleradius.setmap(null);
}
circleradius = new google.maps.marker({
position: event.latlng,
title: centerpointname,
map: map
});
rubbishobject_m.push(circleradius);
} else if (centerpointname == '源点') {
if (originalpoint != null) {
originalpoint.setmap(null);
}
originalpoint = new google.maps.marker({
position: event.latlng,
title: centerpointname,
map: map
});
rubbishobject_m.push(originalpoint);
originalpoint.setdraggable(true);
google.maps.event.addlistener(originalpoint, 'dragend', function () {
window.external.inputtextboxcoordscallback_('textbox14', this.getposition().lng() + ',' + this.getposition().lat());
});
} else if (centerpointname == '目标点') {
if (targetpoint != null) {
targetpoint.setmap(null);
}
targetpoint = new google.maps.marker({
position: event.latlng,
title: centerpointname,
map: map
});
rubbishobject_m.push(targetpoint);
targetpoint.setdraggable(true);
google.maps.event.addlistener(targetpoint, 'dragend', function () {
window.external.inputtextboxcoordscallback_('textbox15', this.getposition().lng() + ',' + this.getposition().lat());
});
}
centerpointname = '';
}
function drawcirclefunc_m(c, r, a1, a2, des, title) {
var cs = c.split(',');
var centerlatlng = getpointbylatlng(cs[1], cs[0]);
var circle = new google.maps.circle({
title: title,
strokecolor: "#ff0000",
strokeopacity: 0.8,
strokeweight: 2,
fillcolor: "#ff0000",
fillopacity: 0.35,
map: map,
center: centerlatlng,
radius: parsefloat(r)
});
enddrawonefig();
addmarkerersarray('circle', circle);
google.maps.event.addlistener(circle, "click", function () {
if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measurecircletareac(this);
}
});
}
function clickobjectdo_m(key) {
dowhat_m = key;
enddrawonefig();
}
function addeventlistenermeasuredistance_m() {
line = null;
drawfigure_m('line');
try {
addeventlistenerdrawfig_m();
google.maps.event.addlistener(map, 'rightclick', clickrightmousemeasuredistance_m);
} catch (err) {
alert("请等待加载地图!");
}
}
function removeeventlistenermeasuredistance_m() {
figtype_m = '';
chushihuadrawfig_m();
dowhat_m = 0;
line = null;
try {} catch (err) {
alert("请等待加载地图!");
}
}
var clickrightmousemeasuredistance_m = function (event) {
if (line != null) {
if (line.getpath().length > 1) {
line.seteditable(false);
}
window.external.measuredistancecallback_(computepathdistance_m(line));
}
}
function computepathdistance_m(obj) {
return google.maps.geometry.spherical.computelength(obj.getpath()).tofixed(2);
}
function computearea(obj) {
return google.maps.geometry.spherical.computearea(obj.getpath()).tofixed(2);
}
function submeasuredistance_m() {
cancellinelaststep_m();
var length = 0;
if (line != null) {
length = computepathdistance_m(line);
}
window.external.measuredistancecallback_(length);
}
function measureobjectlength(obj) {
window.external.measureobjectcallback_(0, 0, computepathdistance_m(obj));
}
function measureobjectareac(obj) {
window.external.measureobjectcallback_(computepathdistance_m(obj), computearea(obj), 0);
}
function measurecircletareac(obj) {
window.external.measureobjectcallback_(2 * math.pi.mul(obj.getradius()), math.pi.mul(obj.getradius()).mul(obj.getradius()), 0);
}
function measureretangleareac(obj) {
var path = [];
var paths = obj.getbounds();
path.push(paths.getsouthwest());
path.push(getpointbylatlng(paths.getnortheast().lat(), paths.getsouthwest().lng()));
path.push(paths.getnortheast());
path.push(getpointbylatlng(paths.getnortheast().lat(), paths.getnortheast().lng()));
window.external.measureobjectcallback_(google.maps.geometry.spherical.computelength(path).tofixed(2), google.maps.geometry.spherical.computearea(path).tofixed(2), 0);
}
var emarker = null;
var wemarker = null;
function editmarker(obj, wobj) {
emarker = obj;
wemarker = wobj;
emarker.setdraggable(true);
window.external.editpointplacemarkcallback_(emarker.gettitle(), getinfowindowcontent(emarker.getposition()));
removeeventlistenerdrawfig_m();
dowhat_m = 2;
}
function modifyplacemark_m(title, description) {
emarker.settitle(title);
setmarkerinfowindowcontent(emarker.getposition(), description);
removeobjectbyclick(wemarker);
var markerinfo = new nameoverlay(emarker.getposition(), title, map);
addmarkerersarray('markerinfo', markerinfo);
google.maps.event.addlistener(emarker, "click", function () {
if (dowhat_m == 0) {
removeobjectbyclick(markerinfo);
} else if (dowhat_m == 2) {
editmarker(this, markerinfo);
}
});
dowhat_m = 2;
}
function endeditplacemark_m() {
emarker.setdraggable(false);
emarker = null;
addeventlistenerdrawfig_m();
}
function correctfigcoords_m(d, h, flag) {
if (markersarray) {
var destpoint = null;
var paths = [];
for (var i = 0; i < markersarray.length; i++) {
var obj = markersarray[i];
if (obj.key == 'marker') {
var markerlatlng = obj.value.getposition();
if (flag == 0) {
destpoint = getpointlocationbydha(new geo.point(markerlatlng.lat(), markerlatlng.lng()), d, h);
} else if (flag == 1) {
var p = window.external.m2w(markerlatlng.lat() + ',' + markerlatlng.lng());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
} else {
var p = window.external.w2m(markerlatlng.lat() + ',' + markerlatlng.lng());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
}
obj.value.setposition(getpointbylatlng(destpoint.lat(), destpoint.lng()));
} else if (obj.key == 'line') {
var linecoords = obj.value.getpath();
var length = linecoords.length;
if (flag == 0) {
for (var j = 0; j < length; j++) {
destpoint = getpointlocationbydha(new geo.point(linecoords.getat(j).lat(), linecoords.getat(j).lng()), d, h);
paths.push(getpointbylatlng(destpoint.lat(), destpoint.lng()));
}
} else {
var sl = '';
for (var j = 0; j < length; j++) {
sl += j > 0 ? ';' : '';
sl += linecoords.getat(j).lat() + ',' + linecoords.getat(j).lng();
}
if (flag == 1) {
var pl = window.external.m2w(sl);
} else {
var pl = window.external.w2m(sl);
}
sl = '';
var pls = pl.split(';');
pl = '';
for (var j = 0; j < length; j++) {
var cl = pls[j].split(',');
paths.push(getpointbylatlng(parsefloat(cl[0]), parsefloat(cl[1])));
}
}
obj.value.setpath(paths);
paths = [];
} else if (obj.key == 'polygon') {
var polygoncoords = obj.value.getpath();
if (flag == 0) {
for (var j = 0; j < polygoncoords.length; j++) {
destpoint = getpointlocationbydha(new geo.point(polygoncoords.getat(j).lat(), polygoncoords.getat(j).lng()), d, h);
paths.push(getpointbylatlng(destpoint.lat(), destpoint.lng()));
if (j == polygoncoords.length - 1 && polygoncoords.getat(j).lng() != polygoncoords.getat(0).lng() && polygoncoords.getat(j).lat() != polygoncoords.getat(0).lat()) {
destpoint = getpointlocationbydha(new geo.point(polygoncoords.getat(0).lat(), polygoncoords.getat(0).lng()), d, h);
paths.push(getpointbylatlng(destpoint.lat(), destpoint.lng()));
}
}
} else {
var sp = '';
for (var j = 0; j < polygoncoords.length; j++) {
sp += j > 0 ? ';' : '';
sp += polygoncoords.getat(j).lat() + ',' + polygoncoords.getat(j).lng();
}
if (flag == 1) {
var pp = window.external.m2w(sp);
} else {
var pp = window.external.w2m(sp);
}
sp = '';
var pps = pp.split(';');
pp = '';
for (var j = 0; j < polygoncoords.length; j++) {
var cl = pps[j].split(',');
paths.push(getpointbylatlng(parsefloat(cl[0]), parsefloat(cl[1])));
}
}
obj.value.setpath(paths);
paths = [];
} else if (obj.key == 'retangle') {
var polygoncoords = obj.value.getbounds();
if (flag == 0) {
destpoint = getpointlocationbydha(new geo.point(polygoncoords.getsouthwest().lat(), polygoncoords.getsouthwest().lng()), d, h);
var destpoint1 = getpointlocationbydha(new geo.point(polygoncoords.getnortheast().lat(), polygoncoords.getnortheast().lng()), d, h);
} else {
if (flag == 1) {
var p = window.external.m2w(polygoncoords.getsouthwest().lat() + ',' + polygoncoords.getsouthwest().lng());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
var p1 = window.external.m2w(polygoncoords.getnortheast().lat() + ',' + polygoncoords.getnortheast().lng());
ps = p1.split(',');
destpoint1 = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
} else {
var p = window.external.w2m(polygoncoords.getsouthwest().lat() + ',' + polygoncoords.getsouthwest().lng());
var ps = p.split(',');
destpoint = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
var p1 = window.external.w2m(polygoncoords.getnortheast().lat() + ',' + polygoncoords.getnortheast().lng());
ps = p1.split(',');
destpoint1 = new geo.point(parsefloat(ps[0]), parsefloat(ps[1]));
}
}
obj.value.setbounds(new google.maps.latlngbounds(getpointbylatlng(destpoint.lat(), destpoint.lng()), getpointbylatlng(destpoint1.lat(), destpoint1.lng())));
} else if (obj.key == 'circle') {
alert('本系统暂时不支持圆坐标校正!');
}
}
}
}
function convertpointtoword(flag) {
if (markersarray) {
if (flag == "1") {
for (var i = 0; i < markersarray.length; i++) {
var shap = markersarray[i].value.getshape();
if (shap != 'circle' && shap != 'poly' && shap != 'rect')
markersarray[i].value.setmap(null);
}
} else {
for (var i = 0; i < markersarray.length; i++) {
var shap = markersarray[i].value.getshape();
if (shap != 'circle' && shap != 'poly' && shap != 'rect')
markersarray[i].value.setmap(map);
}
}
}
}
function addpolygononmap_m(toplat, bottomlat, leftlng, rightlng) {
gotolocationbypoint(new google.maps.latlng(toplat, leftlng), 10);
var bounds = new google.maps.latlngbounds(new google.maps.latlng(bottomlat, leftlng), new google.maps.latlng(toplat, rightlng));
if (polygonbox != null) {
polygonbox.setbounds(bounds);
} else {
polygonbox = new google.maps.rectangle({
clickable: true,
editable: true,
strokecolor: '#0000ff',
strokeopacity: 1.0,
strokeweight: 3,
fillopacity: 0.35,
map: map,
bounds: bounds
});
google.maps.event.addlistener(polygonbox, "click", function () {
if (dowhat_m == 1) {
polygonbox = null;
removeobjectbyclick(this);
} else if (dowhat_m == 3) {
measureobjectareac(this);
}
});
google.maps.event.addlistener(polygonbox, "bounds_changed", function () {
if (dowhat_m == 0) {
getretanglebounds(this);
}
});
addmarkerersarray('retangle', polygonbox);
}
google.maps.event.addlistener(retangle, "mousedown", function () {
if (dowhat_m == 1) {
removeobjectbyclick(this);
} else if (dowhat_m == 0) {
getretanglebounds(this);
} else if (dowhat_m == 3) {
measureretangleareac(this);
}
});
google.maps.event.addlistener(retangle, "bounds_changed", function () {
if (dowhat_m == 0) {
getretanglebounds(this);
}
});
}
function getmaptypeid() {
return map.getmaptypeid();
}
var downloadimagepath = null;
var dippoints = [];
function getpathinfos(obj) {
var state = 1;
var length = 0;
var guaidian = 0;
try {
length = computepathdistance_m(obj);
guaidian = obj.getpath().getlength();
downloadimagepath = obj;
} catch (err) {
state = 0;
}
window.external.returnpathinfos(state, length, guaidian);
}
var dpoints = [];
function getdownloadimagepathinfos() {
var s = "";
dippoints = [];
if (downloadimagepath != null) {
var path = downloadimagepath.getpath();
var length = path.length;
var minlng = path.getat(0).lng();
var maxlng = minlng;
var minlat = path.getat(0).lat();
var maxlat = minlat;
var lngtmp, lattmp;
dippoints[0] = new geo.point(path.getat(0).lat(), path.getat(0).lng());
for (var i = 1; i < length; i++) {
lngtmp = path.getat(i).lng();
minlng = (lngtmp < minlng) ? lngtmp : minlng;
maxlng = (lngtmp > maxlng) ? lngtmp : maxlng;
lattmp = path.getat(i).lat();
minlat = (lattmp < minlat) ? lattmp : minlat;
maxlat = (lattmp > maxlat) ? lattmp : maxlat;
dippoints[i] = new geo.point(path.getat(i).lat(), path.getat(i).lng());
}
s = minlng + ' ' + maxlng + ' ' + minlat + ' ' + maxlat;
}
return s;
}
var ddippoint = [];
function convertpathcoords() {
var pathjson = window.external.modifycoords(getpathpointjson(dippoints));
var ps = pathjson.split(' ');
pathjson = '';
var length = ps.length;
var c = null;
ddippoint = [];
for (var i = 0; i < length; i++) {
c = ps.shift().split(',');
ddippoint[i] = new geo.point(parsefloat(c[1]), parsefloat(c[0]));
}
window.external.convertpathcoordscallback_();
}
function getpathpointjson(p) {
var str = '';
var length = p.length;
for (var i = 0; i < length; i++) {
str += p[i].lng() + ',' + p[i].lat() + ' ';
}
return str.trim();
}
var lastdippoint = null;
function gettilesxy(d, p, k) {
d = parseint(d);
p = parseint(p);
var point = dpoints.shift();
if (k == '0') {
lastdippoint = point;
return point.lng() + ' ' + point.lat();
}
var ipoint = lastdippoint;
var s = '';
var d = gethorizontaldistance(ipoint, point);
var length = math.floor(d.div(d));
for (var i = 1; i <= length; i++) {
ipoint = getpointlocationbydha(ipoint, 2 * p * d, ipoint.heading(point));
s += ipoint.lng() + ' ' + ipoint.lat() + '|';
}
s += point.lng() + ' ' + point.lat();
lastdippoint = point;
return s;
}
function setpathpoints(key) {
if (key == '1') {
dpoints = ddippoint.slice(0);
} else {
dpoints = dippoints.slice(0);
}
ddippoint = [];
}
function cleardownloadimagepoint() {
dippoints = [];
dpoints = [];
}
array.prototype.max = function () {
return math.max.apply({}, this)
}
array.prototype.min = function () {
return math.min.apply({}, this)
}
string.prototype.trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, "");
}
string.prototype.ltrim = function () {
return this.replace(/(^\s*)/g, "");
}
string.prototype.rtrim = function () {
return this.replace(/(\s*$)/g, "");
}
function floatadd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.tostring().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.tostring().split(".")[1].length
} catch (e) {
r2 = 0
}
m = math.pow(10, math.max(r1, r2))
return (arg1 * m + arg2 * m) / m
}
function abs(number) {
return math.abs(number);
}
function sqrt(number) {
return math.sqrt(number);
}
function sqit(number) {
return number * number;
}
function accdiv(arg1, arg2) {
var t1 = 0,
t2 = 0,
r1, r2;
try {
t1 = arg1.tostring().split(".")[1].length
} catch (e) {}
try {
t2 = arg2.tostring().split(".")[1].length
} catch (e) {}
with(math) {
r1 = number(arg1.tostring().replace(".", ""))
r2 = number(arg2.tostring().replace(".", ""))
return (r1 / r2) * pow(10, t2 - t1);
}
}
number.prototype.div = function (arg) {
return accdiv(this, arg);
}
function accmul(arg1, arg2) {
var m = 0,
s1 = arg1.tostring(),
s2 = arg2.tostring();
try {
m += s1.split(".")[1].length
} catch (e) {}
try {
m += s2.split(".")[1].length
} catch (e) {}
return number(s1.replace(".", "")) * number(s2.replace(".", "")) / math.pow(10, m)
}
number.prototype.mul = function (arg) {
return accmul(arg, this);
}
function accadd(arg1, arg2) {
var r1, r2, m;
try {
r1 = arg1.tostring().split(".")[1].length
} catch (e) {
r1 = 0
}
try {
r2 = arg2.tostring().split(".")[1].length
} catch (e) {
r2 = 0
}
m = math.pow(10, math.max(r1, r2))
return (arg1 * m + arg2 * m) / m
}
number.prototype.add = function (arg) {
return accadd(arg, this);
}
function accsub(arg1, arg2) {
return accadd(arg1, -arg2);
}
number.prototype.sub = function (arg) {
return accsub(this, arg);
}
if (!google.maps.polygon.prototype.getbounds) {
google.maps.polygon.prototype.getbounds = function (latlng) {
var bounds = new google.maps.latlngbounds();
var paths = this.getpaths();
var path;
for (var p = 0; p < paths.getlength(); p++) {
path = paths.getat(p);
for (var i = 0; i < path.getlength(); i++) {
bounds.extend(path.getat(i));
}
}
return bounds;
}
}
google.maps.polygon.prototype.containslatlng = function (latlng) {
var bounds = this.getbounds();
if (bounds != null && !bounds.contains(latlng)) {
return false;
}
var inpoly = false;
var numpaths = this.getpaths().getlength();
for (var p = 0; p < numpaths; p++) {
var path = this.getpaths().getat(p);
var numpoints = path.getlength();
var j = numpoints - 1;
for (var i = 0; i < numpoints; i++) {
var vertex1 = path.getat(i);
var vertex2 = path.getat(j);
if (vertex1.lng() < latlng.lng() && vertex2.lng() >= latlng.lng() || vertex2.lng() < latlng.lng() && vertex1.lng() >= latlng.lng()) {
if (vertex1.lat() + (latlng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latlng.lat()) {
inpoly = !inpoly;
}
}
j = i;
}
}
return inpoly;
}
function iscontainslatlng(bounds, paths, latlng) {
if (bounds != null && !bounds.contains(latlng)) {
return false;
}
var inpoly = false;
var numpaths = paths.getlength();
for (var p = 0; p < numpaths; p++) {
var path = paths.getat(p);
var numpoints = path.getlength();
var j = numpoints - 1;
for (var i = 0; i < numpoints; i++) {
var vertex1 = path.getat(i);
var vertex2 = path.getat(j);
if (vertex1.lng() < latlng.lng() && vertex2.lng() >= latlng.lng() || vertex2.lng() < latlng.lng() && vertex1.lng() >= latlng.lng()) {
if (vertex1.lat() + (latlng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latlng.lat()) {
inpoly = !inpoly;
}
}
j = i;
}
}
return inpoly;
}
nameoverlay.prototype = new google.maps.overlayview();
function nameoverlay(point, name, map) {
this.point_ = point;
this.name_ = name;
this.map_ = map;
this.div_ = null;
this.setmap(map);
}
nameoverlay.prototype.onadd = function () {
var div = document.createelement('div');
div.style.border = "none";
div.style.position = "absolute";
var span = document.createelement("span");
var text = document.createtextnode(this.name_);
span.appendchild(text);
div.appendchild(span);
this.div_ = div;
var panes = this.getpanes();
panes.overlayimage.appendchild(div);
}
nameoverlay.prototype.setname = function (name) {
this.name_ = name;
this.onadd();
this.draw();
}
nameoverlay.prototype.draw = function () {
var center = this.getprojection().fromlatlngtodivpixel(this.point_);
this.div_.style.color = 'blue';
this.div_.style.left = center.x + 15;
this.div_.style.top = center.y - 40;
this.div_.style.width = '200px';
}
nameoverlay.prototype.onremove = function () {
this.div_.parentnode.removechild(this.div_);
this.div_ = null;
}
function getrandomnum(min, max) {
var range = max - min;
var rand = math.random();
return (min + math.round(rand * range));
}
function getnormalizedcoord(coord, zoom) {
var y = coord.y;
var x = coord.x;
var tilerange = 1 << zoom;
if (y < 0 || y >= tilerange) {
return null;
}
if (x < 0 || x >= tilerange) {
x = (x % tilerange + tilerange) % tilerange;
}
return {
x: x,
y: y
};
}
function google_fromlnglattoxy(lat, lng, zoom) {
var lnglat = new google.maps.latlng(lat, lng);
var point = map.getprojection().fromlatlngtopoint(lnglat);
var x = point.x / 256.0 * math.pow(2, zoom);
var y = point.y / 256.0 * math.pow(2, zoom);
return x + ',' + y;
}
function google_fromxytolnglat(x, y, zoom) {
var point = new google.maps.point(x / math.pow(2, zoom) * 256.0, y / math.pow(2, zoom) * 256.0);
var lnglat = map.getprojection().frompointtolatlng(point);
return [lnglat.lat(), lnglat.lng()];
}
function tdt_fromxytolnglat(x, y, zoom) {
var lng = x / math.pow(2, zoom) * 360 - 180;
var lat = 90 - y / (0.5 * math.pow(2, zoom)) * 180;
return lat + ',' + lng;
}
function tdt_fromlnglattoxy(lat, lng, zoom) {
var x = (180 + lng) / 360 * math.pow(2, zoom);
var y = (90 - lat) / 180 * 0.5 * math.pow(2, zoom);
return x + ',' + y;
}
function googletilexytobingtilexy(x, y, z) {
var quaddigits = [];
for (var i = z; i > 0; --i) {
var digit = '0';
var mask = 1 << (i - 1);
if ((x & mask) != 0) {
digit++;
}
if ((y & mask) != 0) {
digit++;
digit++;
}
quaddigits.push(digit);
}
var quadkey = quaddigits.join("");
return quadkey;
}
function googletilexytoqqtilexy(x, y, z) {
var tilez = z;
var tilex = x;
var tiley = y;
var scope = new array(0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 7, 0, 7, 0, 15, 0, 15, 0, 31, 0, 31, 0, 63, 4, 59, 0, 127, 12, 115, 0, 225, 28, 227, 356, 455, 150, 259, 720, 899, 320, 469, 1440, 1799, 650, 929, 2880, 3589, 1200, 2069, 5760, 7179, 2550, 3709, 11520, 14349, 5100, 7999, 23060, 28689, 10710, 15429, 46120, 57369, 20290, 29849, 89990, 124729, 41430, 60689, 184228, 229827, 84169, 128886);
var f = tilez * 4;
var i = scope[f++];
var j = scope[f++];
var l = scope[f++];
var scope = scope[f];
if (tilex >= i && tilex <= j && tiley >= l && tiley <= scope) {
tiley = math.pow(2, tilez) - 1 - tiley;
var tileno = tilez + "/" + math.floor(tilex / 16) + "/" + math.floor(tiley / 16) + "/" + tilex + "_" + tiley + this.tileformat;
}
return tileno;
}
function googletilexytobaidutilexy(x, y, z) {
var offsetx = math.pow(2, z - 1);
var offsety = offsetx - 1;
var numx = x - offsetx;
var numy = (-y) + offsety;
var num = (x + y) % 8 + 1;
x = (numx + '').replace("-", "m");
y = (numy + '').replace("-", "m");
return x + ',' + y;
}
function googletilexytosogoutilexy(x, y, z) {
var tilez = z - 1;
var offsetx = math.pow(2, tilez);
var offsety = offsetx - 1;
var bx = x;
var by = y;
var numx = bx - offsetx;
var numy = (-by) + offsety;
tilez = tilez + 1;
var zoomlevel = 729 - tilez;
if (zoomlevel == 710) zoomlevel = 792;
var blo = math.floor(numx / 200);
var bla = math.floor(numy / 200);
var blos, blas;
if (blo < 0)
blos = "m" + (-blo);
else
blos = "" + blo; if (bla < 0)
blas = "m" + (-bla);
else
blas = "" + bla;
x = numx.tostring().replace("-", "m");
y = numy.tostring().replace("-", "m");
return x + ',' + y;
}
function localmaptype(name, alt, minzoom, maxzoom, url, tf) {
this.tilesize = new google.maps.size(256, 256);
this.name = name;
this.alt = alt;
this.maxzoom = parseint(maxzoom);
this.minzoom = parseint(minzoom);
this.url = url;
this.tf = tf;
this.gettile = function (coord, zoom, ownerdocument) {
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
img.onerror = function () {
img.src = "../mymaps/mapback.jpg";
}
img.src = this.url + "/map/" + zoom + "/" + coord.x + "/" + coord.y + this.tf;
return img;
};
}
var localmaptype = null;
function googlemaplayers(name, sl, tl, type, hl, gl, minz, maxz) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = maxz;
this.minzoom = minz;
this.name = name;
this.type = type;
this.sl = sl;
this.tl = tl;
this.hl = hl;
this.gl = gl;
this.gettileurl = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var sn = getrandomnum(0, 3);
return 'http://mt' + sn + '.google.' + this.sl + '/vt/' + this.tl + 'lyrs=' + this.type + '&hl=' + this.hl + '&gl=' + this.gl + '&src=app&x=' + coord.x + '&y=' + coord.y + '&z=' + zoom + '&s=galileo';
};
}
var server = mapserverno == 0 ? 'cn' : 'com';
var lang = maplag == 0 ? 'zh-cn' : 'en';
var diff = mapdiff == 0 ? 'en' : 'cn';
var googlemaptype = new google.maps.imagemaptype(new googlemaplayers('谷歌地图', server, '', 'm@207000000', lang, diff, 2, 20));
var googlesattype = new google.maps.imagemaptype(new googlemaplayers('谷歌卫图', server, '', 's@125', lang, diff, 2, 20));
var googlehybtype = googlesattype;
var googlesatlabeltype = new googlemaplayers('谷歌混合地图', server, 'imgtp=png32&', 'h@207000000', lang, diff, 2, 20);
var googlesatlabeltile = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
img.onerror = function () {}
var sn = getrandomnum(0, 3);
img.src = 'http://mt' + sn + '.google.' + this.sl + '/vt/' + this.tl + 'lyrs=' + this.type + '&hl=' + this.hl + '&gl=' + this.gl + '&src=app&x=' + coord.x + '&y=' + coord.y + '&z=' + zoom + '&s=galileo';
return img;
};
googlesatlabeltype.gettile = googlesatlabeltile;
var googletertype = new google.maps.imagemaptype(new googlemaplayers('谷歌地形图', server, '', 't@130,r@207000000', lang, diff, 2, 15));
function tpgmaplayers(name, minz, maxz) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = maxz;
this.minzoom = minz;
this.name = name;
this.gettileurl = function (coord, zoom, ownerdocument) {
var box = '';
var x = coord.x;
var y = coord.y;
var d = 20037508.34279;
box = 2 * d * x / math.pow(2, zoom) - d;
box += ',' + (-2 * d * (y + 1) / math.pow(2, zoom) + d);
box += ',' + (2 * d * (x + 1) / math.pow(2, zoom) - d);
box += ',' + (-2 * d * y / math.pow(2, zoom) + d);
return 'http://78.46.61.141/cgi-bin/tilecache-2.11/tilecache.py?layers=topomapper_gmerc&format=image%2fjpeg&service=wms&version=1.1.1&request=getmap&styles=&srs=epsg%3a900913&bbox=' + box + '&width=256&height=256';
};
}
var tpgmaptype = new google.maps.imagemaptype(new tpgmaplayers('扫描地形图', 2, 18));
function bingmaplayers(name, u1, u2, u3) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = 18;
this.minzoom = 2;
this.name = name;
this.gettileurl = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var z = zoom;
var quaddigits = [];
for (var i = z; i > 0; --i) {
var digit = '0';
var mask = 1 << (i - 1);
if ((x & mask) != 0) {
digit++;
}
if ((y & mask) != 0) {
digit++;
digit++;
}
quaddigits.push(digit);
}
var quadkey = quaddigits.join("");
var sn = getrandomnum(0, 3);
return u1 + sn + u2 + quadkey + u3;
};
}
var bingmaptype = new google.maps.imagemaptype(new bingmaplayers('必应地图(国内)', 'http://r', '.tiles.ditu.live.com/tiles/r', '.png?g=96&mkt=zh-cn'));
var bingsattype = new google.maps.imagemaptype(new bingmaplayers('必应卫图', 'http://ecn.t', '.tiles.virtualearth.net/tiles/a', '.jpeg?g=1135&n=z'));
var binghybtype = new google.maps.imagemaptype(new bingmaplayers('必应混合地图', 'http://ecn.t', '.tiles.virtualearth.net/tiles/h', '.jpeg?g=1135&n=z'));
function tdtmaplayers(name, type, minz, maxz) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = maxz;
this.minzoom = minz;
this.name = name;
this.type = type;
this.gettileurl = function (coord, level, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, level);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var maptype = '';
if (this.type == "emap") {
maptype = "vec_w";
} else if (this.type == "rmap") {
maptype = "img_w";
} else if (this.type == "tmap") {
maptype = "ter_w";
}
var sn = getrandomnum(0, 7);
return 'http://tile' + sn + '.chinaonmap.com/dataserver?t=' + maptype + '&x=' + x + '&y=' + y + '&l=' + level;
};
}
var tdtmaptype = new google.maps.imagemaptype(new tdtmaplayers('天地图地图', 'emap', 2, 18));
var tdtsattype = new google.maps.imagemaptype(new tdtmaplayers('天地图卫图', 'rmap', 2, 18));
var tdttertype = new google.maps.imagemaptype(new tdtmaplayers('天地图地形图', 'tmap', 2, 14));
function tdtannolayers(name, type, minz, maxz) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = maxz;
this.minzoom = minz;
this.name = name;
this.type = type;
this.gettile = function (coord, level, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, level);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var maptype = '';
if (this.type == "eanno") {
maptype = "cva_w";
} else if (this.type == "ranno") {
maptype = "cia_w";
} else if (this.type == "tanno") {
maptype = "cta_w";
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
img.onerror = function () {}
var sn = getrandomnum(0, 7);
img.src = 'http://tile' + sn + '.chinaonmap.com/dataserver?t=' + maptype + '&x=' + x + '&y=' + y + '&l=' + level;
return img;
};
}
var tdtmaplabeltype = new tdtannolayers('天地图地图注记', 'eanno', 2, 18);
var tdtsatlabeltype = new tdtannolayers('天地图卫图注记', 'ranno', 2, 18);
var tdtterlabeltype = new tdtannolayers('天地图地形图注记', 'tanno', 2, 14);
function qqmaplayers(name, type, tileformat) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = 18;
this.minzoom = 4;
this.name = name;
this.type = type;
this.tileformat = tileformat;
this.gettileurl = function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var tilez = zoom;
var tilex = coord.x;
var tiley = coord.y;
var scope = new array(0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 7, 0, 7, 0, 15, 0, 15, 0, 31, 0, 31, 0, 63, 4, 59, 0, 127, 12, 115, 0, 225, 28, 227, 356, 455, 150, 259, 720, 899, 320, 469, 1440, 1799, 650, 929, 2880, 3589, 1200, 2069, 5760, 7179, 2550, 3709, 11520, 14349, 5100, 7999, 23060, 28689, 10710, 15429, 46120, 57369, 20290, 29849, 89990, 124729, 41430, 60689, 184228, 229827, 84169, 128886);
var f = tilez * 4;
var i = scope[f++];
var j = scope[f++];
var l = scope[f++];
var scope = scope[f];
if (tilex >= i && tilex <= j && tiley >= l && tiley <= scope) {
tiley = math.pow(2, tilez) - 1 - tiley;
var tileno = tilez + "/" + math.floor(tilex / 16) + "/" + math.floor(tiley / 16) + "/" + tilex + "_" + tiley + this.tileformat;
}
var sn = getrandomnum(0, 3);
return 'http://p' + sn + '.map.soso.com/' + this.type + '/' + tileno;
};
}
var sosomaptype = new google.maps.imagemaptype(new qqmaplayers('搜搜地图', 'maptiles', '.png'));
var sososattype = new google.maps.imagemaptype(new qqmaplayers('搜搜卫图', 'satetiles', '.jpg'));
var sososatlabeltype = new qqmaplayers('搜搜卫图标签', 'satetrantiles', '.png');
sososatlabeltype.gettile = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
var tilez = zoom;
var tilex = coord.x;
var tiley = coord.y;
var scope = new array(0, 0, 0, 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, 7, 0, 7, 0, 15, 0, 15, 0, 31, 0, 31, 0, 63, 4, 59, 0, 127, 12, 115, 0, 225, 28, 227, 356, 455, 150, 259, 720, 899, 320, 469, 1440, 1799, 650, 929, 2880, 3589, 1200, 2069, 5760, 7179, 2550, 3709, 11520, 14349, 5100, 7999, 23060, 28689, 10710, 15429, 46120, 57369, 20290, 29849, 89990, 124729, 41430, 60689, 184228, 229827, 84169, 128886);
var f = tilez * 4;
var i = scope[f++];
var j = scope[f++];
var l = scope[f++];
var scope = scope[f];
if (tilex >= i && tilex <= j && tiley >= l && tiley <= scope) {
tiley = math.pow(2, tilez) - 1 - tiley;
var tileno = tilez + "/" + math.floor(tilex / 16) + "/" + math.floor(tiley / 16) + "/" + tilex + "_" + tiley + this.tileformat;
}
var sn = getrandomnum(0, 3);
img.src = 'http://p' + sn + '.map.soso.com/' + this.type + '/' + tileno;
return img;
};
function mapabcmaplayers(name, url, type) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = 18;
this.minzoom = 2;
this.name = name;
this.url = url;
this.type = type;
this.gettileurl = function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var z = zoom;
var sn = getrandomnum(1, 4);
return 'http://web' + this.url + '0' + sn + '.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=' + this.type + '&x=' + x + '&y=' + y + '&z=' + z;
};
}
var mapabcmaptype = new google.maps.imagemaptype(new mapabcmaplayers('高德地图', 'rd', '7'));
var mapabcsattype = new google.maps.imagemaptype(new mapabcmaplayers('高德卫图', 'st', '6'));
var mapabcsatlabeltype = new mapabcmaplayers('高德卫图标签', 'st', '8');
mapabcsatlabeltype.gettile = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
var x = coord.x;
var y = coord.y;
var z = zoom;
var sn = getrandomnum(1, 4);
img.src = 'http://web' + this.url + '0' + sn + '.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=' + this.type + '&x=' + x + '&y=' + y + '&z=' + z;
return img;
};
var wymaptype = new google.maps.imagemaptype({
gettileurl: function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var bx = coord.x;
var by = coord.y;
var z = zoom;
var ngrade = math.ceil((zoom - 5) / 4);
var nprerow = 0;
var nprecol = 0;
var npresize = 0;
var path = "";
for (var i = 0; i < ngrade; ++i) {
var nsize = 1 << 4 * (ngrade - i);
var nrow = parseint((bx - nprerow * npresize) / nsize + "");
var ncol = parseint((by - nprecol * npresize) / nsize + "");
path = path + ((nrow > 9 ? (nrow) : ("0" + nrow)) + "" + (ncol > 9 ? (ncol) : ("0" + ncol)) + "/");
nprerow = nrow;
nprecol = ncol;
npresize = nsize;
}
var id = (((bx) & ((1 << 20) - 1)) + (((by) & ((1 << 20) - 1)) * math.pow(2, 20)) + (((zoom) & ((1 << 8) - 1)) * math.pow(2, 40)));
var sn = getrandomnum(1, 4);
return 'http://cache8.51ditu.com/' + zoom + '/' + path + id + '.png';
}, tilesize: new google.maps.size(256, 256),
maxzoom: 18,
minzoom: 4,
name: "51地图"
});
function baidumaplayers(name, type) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = 18;
this.minzoom = 3;
this.name = name;
this.type = type;
this.gettileurl = function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var offsetx = math.pow(2, zoom - 1);
var offsety = offsetx - 1;
var numx = coord.x - offsetx;
var numy = (-coord.y) + offsety;
var num = (coord.x + coord.y) % 8 + 1;
var x = (numx + '').replace("-", "m");
var y = (numy + '').replace("-", "m");
return 'http://q' + num + '.baidu.com/it/u=x=' + x + ';y=' + y + ';z=' + zoom + this.type;
};
}
var baidumaptype = new google.maps.imagemaptype(new baidumaplayers('百度地图', ';v=015;type=web&fm=44'));
var baidusattype = new google.maps.imagemaptype(new baidumaplayers('百度卫图', ';v=009;type=sate&fm=46'));
var baidusatlabeltype = new baidumaplayers('百度卫图 标签', ';v=015;type=trans&fm=47');
baidusatlabeltype.gettile = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
var offsetx = math.pow(2, zoom - 1);
var offsety = offsetx - 1;
var numx = coord.x - offsetx;
var numy = (-coord.y) + offsety;
var num = (coord.x + coord.y) % 8 + 1;
var x = (numx + '').replace("-", "m");
var y = (numy + '').replace("-", "m");
img.src = 'http://q' + num + '.baidu.com/it/u=x=' + x + ';y=' + y + ';z=' + zoom + this.type;
return img;
};
var emaptype = new google.maps.imagemaptype({
gettileurl: function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var z = 13 - zoom;
var x, y, m;
m = math.pow(2, zoom) / 2;
x = coord.x - m;
y = coord.y - m;
var sn = getrandomnum(1, 4);
return 'http://cpic2.edushi.com/cn/beijing/zh-chs/mappic/png' + z + '/' + x + ',' + y + '.png';
}, tilesize: new google.maps.size(256, 256),
maxzoom: 13,
minzoom: 10,
name: "e都市"
});
function sogoumaplayers(name, url, type, tileformat) {
this.tilesize = new google.maps.size(256, 256);
this.maxzoom = 18;
this.minzoom = 3;
this.name = name;
this.url = url;
this.type = type;
this.tileformat = tileformat;
this.gettileurl = function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var tilez = zoom - 1;
var offsetx = math.pow(2, tilez);
var offsety = offsetx - 1;
var bx = coord.x;
var by = coord.y;
var numx = bx - offsetx;
var numy = (-by) + offsety;
tilez = tilez + 1;
var zoomlevel = 729 - tilez;
if (zoomlevel == 710) zoomlevel = 792;
var blo = math.floor(numx / 200);
var bla = math.floor(numy / 200);
var blos, blas;
if (blo < 0)
blos = "m" + (-blo);
else
blos = "" + blo; if (bla < 0)
blas = "m" + (-bla);
else
blas = "" + bla;
var x = numx.tostring().replace("-", "m");
var y = numy.tostring().replace("-", "m");
var sn = getrandomnum(0, 3);
return 'http://' + this.url + sn + '.go2map.com/' + this.type + zoomlevel + "/" + blos + "/" + blas + "/" + x + "_" + y + this.tileformat;
};
}
var sogoumaptype = new google.maps.imagemaptype(new sogoumaplayers('搜狗地图', 'p', 'seamless1/0/174/', '.gif'));
var sogousattype = new google.maps.imagemaptype(new sogoumaplayers('搜狗卫图', 'hbpic', 'seamless/0/180/', '.jpg'));
var sogousatlabeltype = new sogoumaplayers('搜狗卫图标签', 'hbpic', 'seamless/0/179/', '.png');
sogousatlabeltype.gettile = function (coord, zoom, ownerdocument) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var img = ownerdocument.createelement("img");
img.style.width = this.tilesize.width + "px";
img.style.height = this.tilesize.height + "px";
var tilez = zoom - 1;
var offsetx = math.pow(2, tilez);
var offsety = offsetx - 1;
var bx = coord.x;
var by = coord.y;
var numx = bx - offsetx;
var numy = (-by) + offsety;
tilez = tilez + 1;
var zoomlevel = 729 - tilez;
if (zoomlevel == 710) zoomlevel = 792;
var blo = math.floor(numx / 200);
var bla = math.floor(numy / 200);
var blos, blas;
if (blo < 0)
blos = "m" + (-blo);
else
blos = "" + blo; if (bla < 0)
blas = "m" + (-bla);
else
blas = "" + bla;
var x = numx.tostring().replace("-", "m");
var y = numy.tostring().replace("-", "m");
var sn = getrandomnum(0, 3);
img.src = 'http://' + this.url + sn + '.go2map.com/' + this.type + zoomlevel + "/" + blos + "/" + blas + "/" + x + "_" + y + this.tileformat;
return img;
};
var yahoomaptype = new google.maps.imagemaptype({
gettileurl: function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var z = zoom;
return 'http://img.ditu.aliyun.com/get_png?v=v4&x=' + x + '&y=' + y + '&z=' + z;
}, tilesize: new google.maps.size(256, 256),
maxzoom: 18,
minzoom: 3,
name: "雅虎地图"
});
var yahoosattype = new google.maps.imagemaptype({
gettileurl: function (coord, zoom) {
var normalizedcoord = getnormalizedcoord(coord, zoom);
if (!normalizedcoord) {
return null;
}
var x = coord.x;
var y = coord.y;
var z = zoom;
return 'http://img.ditu.aliyun.com/get_png?v=v4&x=' + x + '&y=' + y + '&z=' + z;
}, tilesize: new google.maps.size(256, 256),
maxzoom: 18,
minzoom: 2,
name: "雅虎地图"
});
function copyrightmaptype() {
this.tilesize = new google.maps.size(256, 256);
}
copyrightmaptype.prototype.gettile = function (coord, zoom, ownerdocument) {
var div = ownerdocument.createelement('div');
div.innerhtml = '<br><br><br><br><br><br><br><p align="center">copyright ©2013 谷地goodygis</p>';
div.style.width = this.tilesize.width + 'px';
div.style.height = this.tilesize.height + 'px';
div.style.fontsize = '14';
div.style.color = '#0000ff';
div.style.borderstyle = 'solid';
div.style.borderwidth = '1px';
div.style.bordercolor = '#aaaaaa';
return div;
};
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <!doctype html> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="wangyaodong"> <meta name="keywords" content=""> <meta name="description" content=", google earth, google map"> <meta http-equiv="x-ua-compatible" content="ie=8"> <style type="text/css"> html { height: 100% } body { height: 100%; width: 100%; margin: 0px; padding: 0px } .bg{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: url(./images/background.jpg) no-repeat #000; z-index: -1; filter:progid:dximagetransform.microsoft.alphaimageloader(src='./images/background.jpg', sizingmethod='scale'); } .ld{ position:absolute; left:30px; top:20px; width: 128px; height: 128px; background:url(ld.png) no-repeat; z-index: 1000001; } .displaymap { width: 100%; height: 100% } .hidemap { width: 0; height: 0 } </style> <script type="text/javascript"> var sys = {}; var ua = navigator.useragent.tolowercase(); var s; (s = ua.match(/rv:([\d.]+)\) like gecko/)) ? sys.ie = s[1] : (s = ua.match(/msie ([\d.]+)/)) ? sys.ie = s[1] : (s = ua.match(/firefox\/([\d.]+)/)) ? sys.firefox = s[1] : (s = ua.match(/chrome\/([\d.]+)/)) ? sys.chrome = s[1] : (s = ua.match(/opera.([\d.]+)/)) ? sys.opera = s[1] : (s = ua.match(/version\/([\d.]+).*safari/)) ? sys.safari = s[1] : 0; if (sys.ie) { //alert('你是使用ie'+sys.ie); //window.location.href="map.html"; } else if (sys.firefox) { //alert('你是使用firefox'+sys.firefox); window.location.href="error.html"; } else if (sys.chrome) { //alert('你是使用chrome'+sys.chrome); window.location.href="error.html"; } else if (sys.opera) { //alert('你是使用opera'+sys.opera); window.location.href="error.html"; } else if (sys.safari) { //alert('你是使用safari'+sys.safari); window.location.href="error.html"; } else { window.location.href="error.html"; } </script> <script type="text/javascript"> var mapserverno=0; var maplag=0; var mapdiff=0; var map=null; var googlemapver='m@207000000'; var googlesatver='s@125'; var googlehybver='h@207000000'; var googleterver='t@130,r@207000000'; function getmapserverandlag(){ var serverlag=window.external.getmapserverandlag_callback().split(','); mapserverno=serverlag[0]; maplag=serverlag[1]; mapdiff=serverlag[2]; } function setmapserverandlag(server,lag,diff){ mapserverno=server; maplag=lag; mapdiff=diff; } getmapserverandlag(); function setgooglemapversion(map,sat,hyb,ter){ if(map!='') googlemapver=map; if(sat!='') googlesatver=sat; if(hyb!='') googlehybver=hyb; if(ter!='') googleterver=ter; } </script> <script type="text/javascript" src="./googlemapapi/mapapi.js"></script> <script type="text/javascript" src='./js/earth.js'></script> <script type="text/javascript" src="./js/jquery.min.js"></script> <script type="text/javascript" src='./js/extensions-0.2.1.pack.js'></script> <script type="text/javascript"> /* <![cdata[ */ var loadearth=false; var loadmap=false; var loadmymap=false; var mousemsgflag=false; var lastmapmod='earth'; var centerpoint=null; var ge=null; var gex=null; var mod='m'; var mymapdir=''; var mymapzoommax=0; var mymapzoommin=0; var clat=31.8; var clng=117.2; var mapzoom=4; var maplayerprojection='googleprojection'; function setmaplayers(maplayer){ if(map!=null){map.maptypes.set('maplayer',eval(maplayer.split('_')[1]+'type'));map.setmaptypeid('maplayer');clearmapoverlayers();} } function setsatlayers(maplayer,overlabel){ setmaplayers(maplayer);if(overlabel!=''){addmapoverlayer(overlabel);} } function setmapoverlayers(overlayer){ map.overlaymaptypes.insertat(0,eval(overlayer.split('_')[1]+'type')); } function clearmapoverlayers(){ map.overlaymaptypes.clear(); } function removemapoverlayers(key){ map.overlaymaptypes.removeat(key); } function addmapoverlayer(overlayer){ setmapoverlayers(overlayer); } function setmaplang(no,id){ maplag=no;lang=maplag==0?'zh-cn':'en';updataggmaplayers(id); } function setmapserver(no,id){ mapserverno=no;server=mapserverno==0?'cn':'com';updataggmaplayers(id); } function setmapdiff(no,id){ mapdiff=no;diff=mapdiff==0?'en':'cn';updataggmaplayers(id); } function updataggmaplayers(id){ googlemaptype=new google.maps.imagemaptype(new googlemaplayers('谷歌地图',server,'',googlemapver,lang,diff,2,20)); googlesattype=new google.maps.imagemaptype(new googlemaplayers('谷歌卫图',server,'',googlesatver,lang,diff,2,20)); googlehybtype=googlesattype;googlesatlabeltype=new googlemaplayers('谷歌混合地图',server,'imgtp=png32&',googlehybver,lang,diff,2,20); googlesatlabeltype.gettile=googlesatlabeltile;googletertype=new google.maps.imagemaptype(new googlemaplayers('谷歌地形图',server,'',googleterver,lang,diff,2,15)); if(id<4&&map!=null){ clearmapoverlayers(); map.maptypes.set('googlemap',googlemaptype); map.maptypes.set('googlesat',googlesattype); map.maptypes.set('googlehyb',googlehybtype); map.maptypes.set('googleter',googletertype); if(id==0){ map.setmaptypeid('googlemap'); }else if(id==1){ map.setmaptypeid('googlesat');}else if(id==2){map.setmaptypeid('googlehyb');map.overlaymaptypes.insertat(0,googlesatlabeltype);}else if(id==3){map.setmaptypeid('googleter'); } } } function setmapmod(mapmod){ if(mapmod=='map'){ showmap(); }else if(mapmod=='mymap'){ } else{ showearth(); } } function showearth(){ $('#map').attr('class','hidemap'); $('#map3d').attr('class','displaymap'); lastmapmod='earth'; } var myoptions=null; function loadedmap(){ var mylatlng=new google.maps.latlng(clat,clng); myoptions={zoom:mapzoom,center:mylatlng,scalecontrol:true,maptypeid:google.maps.maptypeid.roadmap,pancontrol:true, pancontroloptions:{position:google.maps.controlposition.right_top},zoomcontrol:true, zoomcontroloptions:{style:google.maps.zoomcontrolstyle.large,position:google.maps.controlposition.right_top}, streetviewcontrol:true,streetviewcontroloptions:{position:google.maps.controlposition.right_top}} document.getelementbyid('map').innerhtml=''; map=new google.maps.map(document.getelementbyid("map"),myoptions); getmousecoordinates(); getmaplookat(); loadmap=true; lastmapmod='map'; //alert("loadmap"); } function showmap(){ $('#map3d').attr('class','hidemap'); $('#map').attr('class','displaymap'); if(!loadmap){ loadedmap(); } //alert("showmap"); } function setmymapparams(name,tf,lat,lng,dir,zmax,zmin){ var mymapurl='../mymaps/'+dir;var picetx=(tf=='')?'.jpg':tf; gotolocationbypoint(new google.maps.latlng(parsefloat(lat),parsefloat(lng)),parseint(zmin)); localmaptype=new localmaptype('本地','本地地图',zmin,zmax,mymapurl,picetx); clearmapoverlayers(); map.overlaymaptypes.insertat(0,localmaptype); } function getmousecoordinates(){ google.maps.event.addlistener(map,'mousemove', function(event){ var lat=event.latlng.lat().tofixed(6); var lng=event.latlng.lng().tofixed(6); var alt=0; try{ alt=ge.getglobe().getgroundaltitude(lat,lng).tofixed(2); } catch(err){ } window.external.displaylatlngalt(lat,lng,alt); if(mousemsgflag){ window.external.showmsgtrackmouse(); } }); } function getmaplookat(){ google.maps.event.addlistener(map,'bounds_changed', function(){ var mapcenter=map.getcenter(); clat=mapcenter.lat(); clng=mapcenter.lng(); mapzoom=map.getzoom(); window.external.showmapzoom(mapzoom); } ); } function setmaplookat(zoom){ gotolocationbypoint(new google.maps.latlng(clat,clng),zoom); } function setoneventlistenershowmsgmousemove(flag){ mousemsgflag=flag; } function seticonurl(icon,title){ iconurl=icon; markertitle=title; if(lastmapmod=='earth'){ pointstyle={label:{scale:1, color:'white', opacity:1}, icon:{href:iconurl, color:'white', opacity:1, scale:1.1}}; } } function importnetmap(mapname,url,tileformat,minzoom,maxzoom,centerlat,centerlng){ gotolocationbypoint(new google.maps.latlng(parsefloat(centerlat),parsefloat(centerlng)),parseint(minzoom)); localmaptype=new localmaptype(mapname,'远程地图',parseint(minzoom),parseint(maxzoom),url,tileformat); clearmapoverlayers(); map.overlaymaptypes.insertat(0,localmaptype); } /* var n=0; function freshwebpage(){ if(n===0){ window.location.reload(); n=1; alert("refresh0 " + n); } alert("refresh1"); } */ function freshwebpage(){ //alert("refresh1"); window.location.reload(); } function document.onkeydown(){ if(event.keycode==116){ event.keycode=0;event.cancelbubble=true;return false; } } function document.oncontextmenu(){ return false; } /* ]]> */ </script> </head> <body> <div class='displaymap' id="map3d"></div> <div class='hidemap' id="map"></div> </body> </html>
网上有很多关于googleearth开发的博文,但是杂乱,不系统。希望这篇文章能帮助到您。
上一篇: 狗、狼与人的经典笑话