﻿var VirtualEarthMap=Class.create();VirtualEarthMap.ZoomLevelMetersPerPixel={1:78271.52,2:39135.76,3:19567.88,4:9783.94,5:4891.97,6:2445.98,7:1222.99,8:611.50,9:305.75,10:152.87,11:76.44,12:38.22,13:19.11,14:9.55,15:4.78,16:2.39,17:1.19,18:0.60,19:0.30};VirtualEarthMap.ZoomLevelLatLongUnitsPerPixel={7:0.0109863281249};VirtualEarthMap.ReadyStates={STANDBY:0,LOADING:1,READY:2,FAILED: -1};VirtualEarthMap.ReadyState=VirtualEarthMap.ReadyStates.READY;VirtualEarthMap.DEFAULT_MAP_MARKER="/Resource/Map/icons/ix_op_all/24x24/plain/flag_red.gif";VirtualEarthMap.prototype={ak:null,gZ: -1,qg:false,pZ:null,qu:null,cp:null,fZ:null,ht:null,fH:null,hy:null,dr:null,hT:null,jP:[],jT:[],cR:false,bR:null,nD:{left:500,top:40},hw:false,initialize:function(cs,aQ,aC,aD,am,bk,fD){if(VirtualEarthMap.ReadyState!=VirtualEarthMap.ReadyStates.LOADING){VirtualEarthMap.ReadyState=VirtualEarthMap.ReadyStates.READY;}this.bR={level:aQ,lat:aC,lon:aD,style:am};this.km();if(VirtualEarthMap.ReadyState==VirtualEarthMap.ReadyStates.LOADING){this.nC("initialize",this.sA.bind(this,cs,aQ,aC,aD,am,bk,fD));this.nC("setZoomOnPointer",(function(){this.ak.SetMouseWheelZoomToCenter(false);}).bind(this));}else if(VirtualEarthMap.ReadyState==VirtualEarthMap.ReadyStates.FAILED){alert("Loading of VEMap failed.");}else{this.km();this.sA(cs,aQ,aC,aD,am,bk,fD);try{this.ak.SetMouseWheelZoomToCenter(false);}catch(e){}}},sA:function(cs,aQ,aC,aD,am,bk,fD){this.ak=new VEMap(cs);this.hy=[VEMapStyle.Road,VEMapStyle.Aerial,VEMapStyle.Hybrid,VEMapStyle.Birdseye];try{var s=(typeof am!="undefined")?this.hy[am]:this.hy[0];var latlon=new VELatLong(aC,aD);this.gZ=aQ;switch(bk){case "e":bk=VEOrientation.East;break;case "w":bk=VEOrientation.West;break;case "s":bk=VEOrientation.South;break;case "n":default:bk=VEOrientation.North;break;}var kG=new VEMapOptions();kG.EnableDashboardLabels=false;if(am==MapController.Styles.BIRDS_EYE){this.ak.LoadMap(null,null,null,null,null,null,null,kG);this.ak.SetMapStyle(s);this.ak.SetBirdseyeScene(latlon,bk);}else{this.ak.LoadMap(latlon,aQ,s,fD,null,null,null,kG);}this.ak.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);if(typeof fD!="undefined"&&fD==true){this.ak.AttachEvent("onmouseover",function(){return true;});}}catch(e){}this.ak.AttachEvent('onendzoom',this.vi.bind(this));this.ak.AttachEvent('onclick',this.vh.bind(this));this.ak.AttachEvent('onchangeview',this.vn.bind(this));this.ak.AttachEvent('onresize',this.ri.bind(this));this.ak.AttachEvent('onchangemapstyle',this.mq.bind(this));this.cR=true;this.ak.HideDashboard();this.toogleAnimation(true);},toogleAnimation:function(aw){try{this.ak.vemapcontrol.SetAnimationEnabled(aw);}catch(e){}},//-->
yE:function(id,sV,zE){if(id=="ve"){if(sV){VirtualEarthMap.ReadyState=VirtualEarthMap.ReadyStates.READY;this.sC();}else{VirtualEarthMap.ReadyState=VirtualEarthMap.ReadyStates.FAILED;}}},ready:function(){this.cR=true;this.sC();},nC:function(bv,ej){this.jT=this.jT.without(bv);this.jT.push(bv);this.jP.push(ej);},km:function(){try{this.pZ=this.addEventType("onlevelloaded");this.qu=this.addEventType("oncontextmenu");this.cp=this.addEventType("onchangeview");this.fZ=this.addEventType("onresize");this.fH=this.addEventType("internal_onbirdseyeloaded");this.ht=this.addEventType("internal_onbirdseyefailed");}catch(e){}},sC:function(){var i,ao=this.jP.length;for(i=0;i<ao;i++){try{try{this.jP[i]();}catch(exception){}}catch(e){}}this.jP.length=0;this.jT.length=0;},vo:0,cI:function(ej,aP){if(!(VirtualEarthMap.ReadyState==VirtualEarthMap.ReadyStates.READY)){if(typeof aP=="undefined"){aP=new Date().valueOf()+"_"+this.vo++;}this.nC(aP,ej);}else{return ej();}},ve_addEventListener:function(cC,aG){this.cI(this.tg.bind(this,cC,aG));},tg:function(cC,aG){this.ak.AttachEvent(cC,aG);},ve_IsBirdseyeAvailable:function(){if(this.cR){return this.ak.IsBirdseyeAvailable();}else{return false;}},ve_mapResize:function(){if(this.ak!=null){var cf=Utilities.Window.getSize();if(typeof(window.innerWidth)=='number'){this.ak.Resize(cf.width,cf.height);}}},ve_showInfoBoxByShapeId:function(tl,dz){var bx=this.ak.GetShapeByID(tl);this.ve_showInfoBox(bx,dz);},ve_showInfoBox:function(bx,dz){if(bx!=null){this.ak.HideInfoBox();if(typeof dz!="undefined"&&dz!=null){setTimeout((function(bx){this.ak.ShowInfoBox(bx);}).bind(this,bx),dz);}else{this.ak.ShowInfoBox(bx);}}},getType:function(){return "VirtualEarthMap";},getZoomLevel:function(){if(this.cR){return this.gZ;}else{return this.bR.level;}},kd:null,setZoomLevel:function(ax,jd){this.cI(this.tj.bind(this,ax,jd),"setZoomLevel");this.gZ=ax;},tj:function(ax,jd){if(typeof jd!="undefined"&&jd==true){this.kd=jd;}this.ak.SetZoomLevel(ax);this.gZ=ax;},centerAndZoom:function(at){this.cI(this.ud.bind(this,at),"centerAndZoom");if(!this.cR){this.bR.lat=at.lat;this.bR.lon=at.lon;if(typeof at.level!="undefined"){this.bR.level=at.level;}}},ud:function(at){if(this.getMapStyle()!=MapController.Styles.BIRDS_EYE){var dG=new VELatLong(at.lat,at.lon);this.ak.SetCenterAndZoom(dG,at.level);}else{this.mE(at);}this.gZ=this.ak.GetZoomLevel();},center:function(at){this.cI(this.ur.bind(this,at),"center");if(!this.cR){this.bR.lat=at.lat;this.bR.lon=at.lon;}},ur:function(at){if(this.getMapStyle()!=MapController.Styles.BIRDS_EYE){var dG=new VELatLong(at.lat,at.lon);this.ak.SetCenter(dG);}else{this.mE(at);}},getCenter:function(){if(this.cR){if(this.getMapStyle()==MapController.Styles.BIRDS_EYE){try{var gk=this.ak.GetBirdseyeScene();var cU=gk.GetBoundingRectangle();var jg=cU.TopLeftLatLong;var iV=cU.BottomRightLatLong;return{lat:(jg.Latitude+iV.Latitude)/2,lon:(jg.Longitude+iV.Longitude)/2};}catch(e){var latlon=this.ak.GetCenter();return{lat:latlon.Latitude,lon:latlon.Longitude};}}else{var latlon=this.ak.GetCenter();return{lat:latlon.Latitude,lon:latlon.Longitude};}}else{return{lat:this.bR.lat,lon:this.bR.lon};}},getCenterUTM:function(){if(this.cR){var dG=this.ak.GetCenter();return Utilities.Trans.decimalDegreesToUTM({x:latlon.Longitude,y:latlon.Latitude});}else{return Utilities.Trans.decimalDegreesToUTM({x:this.bR.lon,y:this.bR.lat});}},getPixelLatLon:function(sb){if(this.cR){var p=new VEPixel(sb.x,sb.y);var dG=this.ak.PixelToLatLong(p);return{lat:dG.Latitude,lon:dG.Longitude};}else{return{lat:this.bR.lat,lon:this.bR.lon};}},getLatLonPixel:function(lat,lon){if(this.cR){var dG=new VELatLong(lat,lon);return this.ak.LatLongToPixel(dG);}else{return{x:0,y:0};}},getMapStyle:function(){if(this.cR){var s=this.ak.GetMapStyle();if(s==VEMapStyle.Road)return MapController.Styles.REGULAR;if(s==VEMapStyle.Aerial)return MapController.Styles.AERIAL;if(s==VEMapStyle.Hybrid)return MapController.Styles.HYBRID;if(s==VEMapStyle.Birdseye)return MapController.Styles.BIRDS_EYE;}else{return(typeof this.bR.style!="undefined")?this.bR.style:MapController.Styles.REGULAR;}},mK:[0,1,2,3],setMapStyle:function(am){var bL=this.cI(this.tw.bind(this,am),"setMapStyle");return!$defined(bL)?true:bL;},tw:function(am){if(this.mK.include(am)){this.ak.SetMapStyle(this.hy[am]);if(am!=MapController.Styles.BIRDS_EYE){this.sJ();}else{this.kc();}if(this.getMapStyle()==am){return true;}else{return false;}}},isBirdseyeAvailable:function(){if(this.cR){return this.ak.IsBirdseyeAvailable();}else{return true;}},pan:function(x,y){this.cI(this.tq.bind(this,-x,-y),"pan");},tq:function(xdir,ydir){var center=this.ak.LatLongToPixel(this.ak.GetCenter());var pixel=new VEPixel(parseInt(center.x+xdir),parseInt(center.y+ydir));var latlong=this.ak.PixelToLatLong(pixel);this.ak.PanToLatLong(latlong);},resize:function(aO,aJ){this.cI(this.ts.bind(this,aO,aJ),"resize");},ts:function(width,height){this.qg=true;if(width==undefined){if(this.ak!=null){var cf=Utilities.Window.getSize();this.ak.Resize(cf.width,cf.height);}}else{this.ak.Resize(width,height);}if(this.getMapStyle()==MapController.Styles.BIRDS_EYE){this.kc();}},kc:function(){this.ak.ShowMiniMap(this.nD.left,this.nD.top);try{$("MSVE_minimap_resize").style.visibility="hidden";$("MSVE_minimap_h_style_button").style.visibility="hidden";$("MSVE_minimap_r_style_button").style.visibility="hidden";var oe=$("MSVE_minimap");var tD=$("minimapPlaceholder");oe.style.left="25px";tD.appendChild(oe);}catch(e){}},sJ:function(){this.ak.HideMiniMap();},getViewport:function(){if(this.cR){var ik;if(this.getMapStyle()!=MapController.Styles.BIRDS_EYE){ik=this.ak.GetMapView();}else{var gk=this.ak.GetBirdseyeScene();ik=gk.GetBoundingRectangle();}if(ik!=null){var topleft=ik.TopLeftLatLong;var bottomright=ik.BottomRightLatLong;return{minLat:bottomright.Latitude,south:bottomright.Latitude,minLon:topleft.Longitude,west:topleft.Longitude,maxLat:topleft.Latitude,north:topleft.Latitude,maxLon:bottomright.Longitude,east:bottomright.Longitude,width:this.ak.GetWidth(),height:this.ak.GetHeight()};}}return{minLat:this.bR.lat-1,south:this.bR.lat-1,maxLat:this.bR.lat+1,north:this.bR.lat+1,minLon:this.bR.lon-1,west:this.bR.lon-1,maxLon:this.bR.lon+1,east:this.bR.lon+1,width:1024,height:768};},addMarker:function(bf,dQ,ef,aS,aW,fL,gv,fo,fv){this.cI(this.ut.bind(this,bf,dQ,ef,aS,aW,fL,gv,fo,fv));},yu:0,ut:function(icon,northing,easting,title,description,lowerbound,upperbound,iconXOffset,iconYOffset){var marker=icon?icon:this.DEFAULT_MAP_MARKER;var point=new VELatLong(northing,easting);var pin=new VEPushpin("vePin_"+this.yu++,point,marker,$defined(title)?title:"",$defined(description)?description:"");this.ak.AddPushpin(pin);},drawLine:function(id,dY,ek,ox,aO){this.cI(this.sT.bind(this,id,dY,ek,ox,aO));},sT:function(id,dY,ek,ox,aO){this.hT=id;if(this.dr==null){this.dr=new VEShapeLayer();this.ak.AddShapeLayer(this.dr);}else{this.dr.DeleteAllShapes();}if(this.getMapStyle()==MapController.Styles.BIRDS_EYE){this.dr.Hide();}else{this.dr.Show();}var i,ao=dY.length;var bs=90,bu=180,bp= -90,bo= -180;var rG=new Array(ao);for(i=0;i<ao;i++){rG[i]=new VELatLong(dY[i],ek[i]);if(dY[i]<bs)bs=dY[i];if(dY[i]>bp)bp=dY[i];if(ek[i]<bu)bu=ek[i];if(ek[i]>bo)bo=ek[i];}var color=new VEColor(0,0,255,0.7);var kw=new VEShape(VEShapeType.Polyline,rG);kw.SetLineWidth(3);kw.SetLineColor(color);kw.HideIcon();this.dr.AddShape(kw);},hideLine:function(id){this.cI(this.sU.bind(this,id));},sU:function(id){if(id==this.hT&&this.hT!=null){this.dr.Hide();}},showLine:function(id){this.cI(this.tf.bind(this,id));},tf:function(id){if(id==this.hT&&this.hT!=null){this.dr.Show();}},rk:function(){return(this.cR)?this.ak.GetBirdseyeScene():null;},ny:function(at){this.cI(this.mE.bind(this,at));},mE:function(at){var xS=new VELatLong(at.lat,at.lon);var pH=this.getMapStyle()!=MapController.Styles.BIRDS_EYE;this.ak.SetBirdseyeScene(xS,VEOrientation.North,1,(function(gk,pH){if(gk!=null&&$defined(gk.GetID)){this.fH.fire(gk.GetOrientation());this.kc();}else{this.sJ();setTimeout((function(){this.ht.fire();}).bind(this),1);}}).bindAsEventListener(this,pH));},rq:function(bk){this.cI(this.sZ.bind(this,bk));},sZ:function(bk){this.ak.SetBirdseyeOrientation(bk);},uA:function(veStyle){var i,ao=this.hy.length;for(i=0;i<ao;i++){if(this.hy[i]==veStyle){return i;}}},vi:function(event){this.gZ=event.zoomLevel;this.pZ.fire(parseInt(event.zoomLevel));},vh:function(bi){if(bi.rightMouseButton){var dG=this.ak.PixelToLatLong(new VEPixel(bi.mapX,bi.mapY));this.qu.fire(bi.mapX,bi.mapY,dG.Latitude,dG.Longitude);}},vn:function(event){if(this.kd!=null&&this.kd==event.zoomLevel){this.kd=null;return;}var latlon=this.getCenter();this.cp.fire(latlon.lat,latlon.lon,event.zoomLevel,this.uA(event.mapStyle),true);this.qg=false;},ri:function(event){this.nD={left:this.ak.GetWidth()-190,top:50};if(this.getMapStyle()==MapController.Styles.BIRDS_EYE){this.kc();}this.fZ.fire();},mq:function(bi){if(bi.mapStyle=='o'){this.fH.fire(this.ak.GetBirdseyeScene().GetOrientation());}}};Object.extend(VirtualEarthMap,AbstractMap);Object.extend(VirtualEarthMap.prototype,new AbstractEventTrigger());var __vemapLoaded=true;