var map,cent,points=[],points360A=[],points360B=[],Polylines=[],Polylines360A=[],Polylines360B=[],cpmarker,myhome,cpline,pcnt,pcnt360,test,ua={},maplsc;function GMap_OnZoom(a,b){draw8();window.status="Zoom="+b}function GMap_OnMoveStart(){reCpLayer();cpmarker&&map.removeOverlay(cpmarker);document.getElementById("map").focus()}function GMap_OnMove(){document.getElementById("disp_realtime").checked||calc_latlon()} function GMap_OnMoveEnd(){set_cp();setVisible("cpicon",0);calc_latlon();document.getElementById("map").focus()}function GMap_OnMaptypeChanged(){map.getCurrentMapType()==G_SATELLITE_3D_MAP&&document.getElementById("disp_8line").checked&&alert("\u65b9\u4f4d\u7dda\uff08\u9752\u7dda\uff09\u306f\u3001EarthView \u3067\u306f\u6b63\u3057\u304f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002\n\u6b63\u65b9\u4f4d\u7dda\uff08\u8d64\u7dda\uff09\u3092\u304a\u4f7f\u3044\u304f\u3060\u3055\u3044\u3002")} function iniZoomControl(){var a=map.getCenter();a=map.getZoom();if(a>20)a=20;else if(a<2)a=2;a=map.getMapTypes();for(var b=0;b<a.length;b++){a[b].getMinimumResolution=function(){return 2};a[b].getMaximumResolution=function(){return 20}}} function calc_latlon(){var a=map.getCenter();document.getElementById("now_lng").innerHTML=a.lng();document.getElementById("now_lat").innerHTML=a.lat();document.getElementById("disp_cpline").checked&&draw_cpline();var b=getD2000();document.getElementById("d2000_flg").checked||(b=0);a="syu="+document.getElementById("syu").value+"&hmlat="+cent.lat()+"&hmlon="+cent.lng()+"&cplat="+a.lat()+"&cplon="+a.lng()+"&anglew="+b;setFlashVariables("en_view",a)} function set_cpline(){if(document.getElementById("disp_cpline").checked)draw_cpline();else cpline&&map.removeOverlay(cpline)}function draw_cpline(){var a=map.getCenter();cpline&&map.removeOverlay(cpline);var b=[];b.push(new GLatLng(a.y,a.x,false));b.push(new GLatLng(cent.y,cent.x,false));cpline=new GPolyline(b,"#009900",3,0.5);map.addOverlay(cpline)} function load(){if(typeof GBrowserIsCompatible=="function"){if(GBrowserIsCompatible()){if(document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG","1.1"))_mSvgForced=_mSvgEnabled=true;getUA();document.getElementById("maperr").innerHTML="\u521d\u671f\u5316\u4e2d\u30fb\u30fb\u30fb";if(typeof GMap2=="undefined")alert("\u30d6\u30e9\u30a6\u30b6\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u304c\u58ca\u308c\u3066\u308b\u304b\u3082(^^; \n\u624b\u52d5\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u30af\u30ea\u30a2\u3057\u3066\u30d6\u30e9\u30a6\u30b6\u3092\u518d\u8d77\u52d5\u3057\u3066\u307f\u3066\u306d\u3002"); else{var a=GetCookie("mylat"),b=GetCookie("mylng");if(a=="")a=35.362856;if(b=="")b=138.730896;map=new GMap2(document.getElementById("map"));map.addControl(new GLargeMapControl);map.addControl(new GMapTypeControl);map.addControl(new GScaleControl);map.addControl(new GOverviewMapControl);map.addMapType(G_SATELLITE_3D_MAP);map.enableDoubleClickZoom();map.enableContinuousZoom();map.enableScrollWheelZoom();iniZoomControl();for(map.setCenter(new GLatLng(a,b),6);!map.isLoaded(););GEvent.addListener(map, "zoomend",GMap_OnZoom);GEvent.addListener(map,"movestart",GMap_OnMoveStart);GEvent.addListener(map,"moveend",GMap_OnMoveEnd);GEvent.addListener(map,"move",GMap_OnMove);GEvent.addListener(map,"maptypechanged",GMap_OnMaptypeChanged);map.addControl(new google.maps.LocalSearch,new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(130,15)));setCpLayer();set_home();resize();map.setCenter(cent);setbanner()}}}else document.getElementById("maperr").innerHTML="GoogleMaps\u306b\u63a5\u7d9a\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f('A`)"} function set_cp(){cpmarker&&map.removeOverlay(cpmarker);var a=new GIcon;a.image="img/cp.png";a.printImage="img/cp_p.gif";a.mozPrintImage="img/cp_p.gif";a.iconSize=new GSize(100,100);a.iconAnchor=new GPoint(50,50);a.shadowSize=new GSize(0,0);cpmarker=new GMarker(map.getCenter(),a);map.addOverlay(cpmarker)}function pan_home(){map.panTo(cent)} function set_home(){cent=map.getCenter();document.getElementById("cp_lng").innerHTML=cent.lng();document.getElementById("cp_lat").innerHTML=cent.lat();var a=getD2000(),b,c;if(a>=0){b="(\u897f\u504f)";c=""}else{b="(\u6771\u504f)";c="<b>\u203b\u56fd\u5916\u306f\u504f\u89d2\u304c\u6b63\u3057\u304f\u51fa\u307e\u305b\u3093</b>"}document.getElementById("cp_angle").innerHTML=b+a;document.getElementById("angle_lbl").innerHTML=c;SetCookie("mylat",cent.lat());SetCookie("mylng",cent.lng());draw_home();draw8(); draw8_360()}function draw_home(){myhome&&map.removeOverlay(myhome);myhome=new GMarker(cent,{draggable:false});map.addOverlay(myhome)}function deg2rad(a){return a*Math.PI/180}function rad2deg(a){return a*180/Math.PI}function setPoints(a,b,c,d){pcnt||(pcnt=8);var g=pcnt,f=GPoint,e=map.fromLatLngToDivPixel(cent);f.x=e.x+Math.cos(Math.PI*2/g*(d+1)+deg2rad(b-c))*a;f.y=e.y+Math.sin(Math.PI*2/g*(d+1)+deg2rad(b-c))*a;f=map.fromDivPixelToLatLng(f);points.push(new GLatLng(f.y,f.x,false));return true} function drawLine(){pcnt||(pcnt=8);var a=pcnt,b=[];b[8]=[3,3,3,3];b[12]=[1,4,4,1,4,4];b[24]=[4,1,1,4,1,1,4,1,1,4,1,1];for(var c=0;c<a/2;c++){var d=[];d.push(new GLatLng(points[c].y,points[c].x,false));d.push(new GLatLng(points[c+a/2].y,points[c+a/2].x,false));Polylines[c]=new GPolyline(d,"#0000ff",b[a][c],0.5);map.addOverlay(Polylines[c])}return true} function lines_cls(){pcnt||(pcnt=8);for(var a=pcnt/2,b=0;b<a;b++)Polylines[b]&&map.removeOverlay(Polylines[b]);myhome&&map.removeOverlay(myhome);draw_home();set_cp()} function draw8(){lines_cls();if(document.getElementById("disp_8line").checked){document.getElementById("autoline").style.visibility="visible";document.getElementById("autoline_lbl").style.visibility="visible";if(document.getElementById("autoline").checked){document.getElementById("len").style.width="5px";document.getElementById("len").style.visibility="hidden";document.getElementById("len_lbl").style.visibility="visible"}else{document.getElementById("len").style.width="100px";document.getElementById("len_lbl").innerHTML= "";document.getElementById("len").style.visibility="visible";document.getElementById("len_lbl").style.visibility="hidden"}}else{document.getElementById("autoline").style.visibility="hidden";document.getElementById("autoline_lbl").style.visibility="hidden";document.getElementById("len").style.visibility="hidden";document.getElementById("len_lbl").style.visibility="hidden"}if(document.getElementById("d2000_flg").checked)document.getElementById("cp_angle").style.color="#000000";else document.getElementById("cp_angle").style.color= "#a0a0a0";if(document.getElementById("disp_8line").checked){var a=document.getElementById("syu").value;if(a=="45"){pcnt=8;draw8_45()}else if(a=="3060"){pcnt=8;draw8_3060()}else if(a=="3012"){pcnt=12;draw8_3012()}else if(a=="4524"){pcnt=24;draw8_4524()}else{pcnt=8;draw8_3060()}}calc_latlon()} function draw8_45(){var a=document.getElementById("len").value;if(document.getElementById("autoline").checked)a=getAutoLength()*convZoomTo50km();else a*=convZoomTo50km();var b=getD2000();document.getElementById("d2000_flg").checked||(b=0);points=[];for(var c=0;c<8;c++)setPoints(a,22.5,b,c);setPoints(a,22.5,b,0);drawLine()} function draw8_3060(){var a=document.getElementById("len").value;if(document.getElementById("autoline").checked)a=getAutoLength()*convZoomTo50km();else{document.getElementById("len_lbl").innerHTML="";a*=convZoomTo50km()}var b=getD2000();document.getElementById("d2000_flg").checked||(b=0);points=[];setPoints(a,30,b,0);setPoints(a,15,b,1);setPoints(a,30,b,2);setPoints(a,15,b,3);setPoints(a,30,b,4);setPoints(a,15,b,5);setPoints(a,30,b,6);setPoints(a,15,b,7);setPoints(a,30,b,0);drawLine()} function draw8_3012(){var a=document.getElementById("len").value;if(document.getElementById("autoline").checked)a=getAutoLength()*convZoomTo50km();else a*=convZoomTo50km();var b=getD2000();document.getElementById("d2000_flg").checked||(b=0);points=[];for(var c=0;c<12;c++)setPoints(a,15,b,c);setPoints(a,15,b,0);drawLine()} function draw8_4524(){var a=document.getElementById("len").value;if(document.getElementById("autoline").checked)a=getAutoLength()*convZoomTo50km();else a*=convZoomTo50km();var b=getD2000();document.getElementById("d2000_flg").checked||(b=0);points=[];for(var c=0;c<24;c++)setPoints(a,7.5,b,c);setPoints(a,7.5,b,0);drawLine()} function getD2000(){var a=cent.lat()-37,b=cent.lng()-138;return 7.61903333333333+0.360366666666667*a-0.127866666666667*b+0.00703333333333333*a*a-0.00533333333333333*a*b-0.01125*b*b}function GetCookie(a){var b=document.cookie+";";a=b.indexOf(a,0);if(a!=-1){b=b.substring(a,b.length);a=b.indexOf("=",0)+1;var c=b.indexOf(";",a);return unescape(b.substring(a,c))}return""}function SetCookie(a,b){document.cookie=a+"="+escape(b)+";expires=Fri, 31-Dec-2030 23:59:59;"} function resize(){var a=document.getElementById("map"),b=getDispSize();a.style.width=b.width-240+"px";a.style.height=b.height-100+"px";if(map){map.checkResize();a=map.getCenter();map.panTo(a)}} function getDispSize(){if(document.all)return window.opera?{width:document.body.clientWidth,height:document.body.clientHeight}:{width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};else if(document.layers||document.getElementById)return{width:window.innerWidth,height:window.innerHeight}} function getUA(){var a=navigator.userAgent;ua.Opera=a.match(/Opera[\/\s]([0-9]\.[0-9]+)/)?parseFloat(RegExp.$1):0;ua.MSIE=a.match(/MSIE ([0-9]\.[0-9]+)/)&&!ua.Opera?parseFloat(RegExp.$1):0;ua.Firefox=a.match(/Firefox[\/\s]([0-9]\.[0-9]+)/)?parseFloat(RegExp.$1):0;ua.Netscape=a.match(/Netscape[0-9]?[\/\s]([0-9]\.[0-9]+)/)?parseFloat(RegExp.$1):0;ua.Safari=a.match(/Safari/)?1:0;ua.Gecko=a.match(/Netscape|Firefox/)?true:false} function setCpLayer(){var a="";a="position: absolute; z-index:101; width:100px; height:100px; "+(!ua.Opera?"display: none;":"visibility: hidden;")+" ";if(ua.MSIE&&ua.MSIE<7){a+=" filter :progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/cp.png',sizingmethod=image);";a='<div id="cpicon" style="'+a+'"></div>\n'}else a='<img id="cpicon" src="img/cp.png" width=100 height=100 alt="" style="'+a+'" />\n';document.getElementById("cptmp").innerHTML=a} function reCpLayer(){var a=document.getElementById("map"),b=String(a.offsetLeft+(a.offsetWidth-99)/2)+"px";a=String(a.offsetTop+(a.offsetHeight-99)/2)+"px";document.getElementById("cpicon").style.left=b;document.getElementById("cpicon").style.top=a;document.getElementById("cpicon").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/cp.png',sizingmethod=image)";setVisible("cpicon",1);document.getElementById("map").focus()} function setVisible(a,b){var c=document.getElementById(a);if(!c)return false;if(ua.Opera)c.style.visibility=b?"visible":"hidden";else c.style.display=b?"block":"none";return true}function convZoomTo50km(){return[0.384,0.768,1.537,3.075,6.15,12.3,24.5,49,98,195,390,780,1575,3150,6300,12500,25E3,5E4,1E5,2E5,4E5][map.getZoom()]} function getAutoLength(){var a=[300,200,150,100,60,60,40,20,10,4,2,1.5,0.6,0.6,0.4,0.4,0.2,0.2,0.1,0.1,0.05];if(ua.Opera)a=[300,200,150,80,60,40,20,10,10,4,2,1.5,0.6,0.6,0.4,0.4,0.2,0.2,0.1,0.1,0.05];var b=map.getZoom();a=a[b];document.getElementById("len_lbl").innerHTML="\uff1a\u7d04 "+50*a+"km(Zoom:"+b+")";return a} function setPoints360(a,b){var c=cent.lat(),d=cent.lng(),g,f,e;g=(90-c)*Math.atan(1)*4/180;c=a/6378.14;if(c>Math.atan(1)*4*2)c-=Math.atan(1)*4*2;e=Math.cos(c)*Math.cos(g)+Math.sin(c)*Math.sin(g)*Math.cos(b*Math.atan(1)/45);f=e==1?0:Math.sqrt(1-e*e);if(Math.sin(g)*f==0)f=0;else{f=(Math.cos(c)-Math.cos(g)*e)/(Math.sin(g)*f);if(f>1)f=1;if(f<-1)f=-1}e=e;g=Math.sqrt(-1*e*e+1)==0?Math.atan(1)*2:Math.atan(-e/Math.sqrt(-e*e+1))+2*Math.atan(1);g=90-g*180/(Math.atan(1)*4);e=f;f=e==1?0:e==-1?Math.atan(1)*4: Math.sin(b*Math.atan(1)/45)>=0?Math.atan(-1*e/Math.sqrt(-1*e*e+1))+2*Math.atan(1):-1*(Math.atan(-1*e/Math.sqrt(-1*e*e+1))+2*Math.atan(1));if(c>Math.atan(1)*4)f=-f;f=f*180/(Math.atan(1)*4);d=eval(d)+f;if(d>180){d-=360;d-=0;g-=0;points360B.push(new GLatLng(g,d,false));test==3&&GLog.write("points360B1.lon= "+d)}else if(d<-180){d+=360;d-=0;g-=0;points360B.push(new GLatLng(g,d,false));test==3&&GLog.write("points360B2.lon= "+d)}else{d-=0;g-=0;points360A.push(new GLatLng(g,d,false));test==3&&GLog.write("points360A.lon= "+ d)}}function draw8Line360(a,b,c,d){points360A=[];points360B=[];setPoints360(0,b);for(var g=1;g<100;g++)setPoints360(c/100*g,b);if(points360A.length>0){Polylines360A[a]=new GPolyline(points360A,"#ff0000",d,0.5);map.addOverlay(Polylines360A[a])}if(points360B.length>0){Polylines360B[a]=new GPolyline(points360B,"#ff0000",d,0.5);map.addOverlay(Polylines360B[a])}} function lines360_cls(){pcnt360||(pcnt360=8);for(var a=pcnt360,b=0;b<a;b++){Polylines360A!=null&&Polylines360A[b]!=null&&map.removeOverlay(Polylines360A[b]);Polylines360B!=null&&Polylines360B[b]!=null&&map.removeOverlay(Polylines360B[b])}} function draw8_360(){if(document.getElementById("disp_line360").checked){lines360_cls();var a=document.getElementById("syu").value;if(a=="45"){pcnt360=8;draw8_45_360()}else if(a=="3060"){pcnt360=8;draw8_3060_360()}else if(a=="3012"){pcnt360=12;draw12_3060_360()}else if(a=="4524"){pcnt360=24;draw24_45_360()}else{pcnt360=8;draw8_45_360()}}else lines360_cls();calc_latlon()} function draw8_45_360(){var a=getD2000();document.getElementById("d2000_flg").checked||(a=0);var b=6378.14*Math.PI;draw8Line360(0,22.5-a,b,4);draw8Line360(1,67.5-a,b,4);draw8Line360(2,112.5-a,b,4);draw8Line360(3,157.5-a,b,4);draw8Line360(4,202.5-a,b,4);draw8Line360(5,247.5-a,b,4);draw8Line360(6,292.5-a,b,4);draw8Line360(7,337.5-a,b,4)} function draw8_3060_360(){var a=getD2000();document.getElementById("d2000_flg").checked||(a=0);var b=6378.14*Math.PI;draw8Line360(0,15-a,b,4);draw8Line360(1,75-a,b,4);draw8Line360(2,105-a,b,4);draw8Line360(3,165-a,b,4);draw8Line360(4,195-a,b,4);draw8Line360(5,255-a,b,4);draw8Line360(6,285-a,b,4);draw8Line360(7,345-a,b,4)} function draw12_3060_360(){var a=getD2000();document.getElementById("d2000_flg").checked||(a=0);var b=6378.14*Math.PI;draw8Line360(0,15-a,b,4);draw8Line360(1,45-a,b,2);draw8Line360(2,75-a,b,4);draw8Line360(3,105-a,b,4);draw8Line360(4,135-a,b,2);draw8Line360(5,165-a,b,4);draw8Line360(6,195-a,b,4);draw8Line360(7,225-a,b,2);draw8Line360(8,255-a,b,4);draw8Line360(9,285-a,b,4);draw8Line360(10,315-a,b,2);draw8Line360(11,345-a,b,4)} function draw24_45_360(){var a=getD2000();document.getElementById("d2000_flg").checked||(a=0);var b=6378.14*Math.PI+100;draw8Line360(0,7.5-a,b,2);draw8Line360(1,22.5-a,b,4);draw8Line360(2,37.5-a,b,2);draw8Line360(3,52.5-a,b,2);draw8Line360(4,67.5-a,b,4);draw8Line360(5,82.5-a,b,2);draw8Line360(6,97.5-a,b,2);draw8Line360(7,112.5-a,b,4);draw8Line360(8,127.5-a,b,2);draw8Line360(9,142.5-a,b,2);draw8Line360(10,157.5-a,b,4);draw8Line360(11,172.5-a,b,2);draw8Line360(12,187.5-a,b,2);draw8Line360(13,202.5- a,b,4);draw8Line360(14,217.5-a,b,2);draw8Line360(15,232.5-a,b,2);draw8Line360(16,247.5-a,b,4);draw8Line360(17,262.5-a,b,2);draw8Line360(18,277.5-a,b,2);draw8Line360(19,292.5-a,b,4);draw8Line360(20,307.5-a,b,2);draw8Line360(21,322.5-a,b,2);draw8Line360(22,337.5-a,b,4);draw8Line360(23,352.5-a,b,2)};
