var GlogalmarkerArray=[];function trigmaker(A){GEvent.trigger(GlogalmarkerArray[A],"click");}YAHOO.chatr.map=function(AD,P){GMap2.prototype.centerAndZoomOnBounds=function(AK,AH){var AF=(AH.getNorthEast().lat()+AH.getSouthWest().lat())/2;var AJ=(AH.getNorthEast().lng()+AH.getSouthWest().lng())/2;var AE=new GLatLng(AF,AJ);var AI=AK.getBoundsZoomLevel(AH);var AG=AK.getCurrentMapType().getMaximumResolution();if(AI>AG){AI=AG;}if(AI>14){AI=14;}AK.setCenter(AE,AI);};var j=this;var f=0;var B=1;var X=0;var d=new GLatLngBounds();var I=[];var z=[];var i;var O;var C;var q=P.mapmode;var U=P.pointlmt;var A=P.markerJSON;var c=P.polyJSON;var AB=P.overview;var h=P.ovcollapse;var V=P.havebeen;var D=P.bigmap;var r=P.MenuType;this.mapcontainer=AD;this.markmadeCallback=null;this.markremoveCallback=null;this.havebeenCallback=null;this.bigmapCallback=null;this.markbtnCallback=null;this.polymadeCallback=null;this.activeMarker=null;if(!q){q=0;}var v=[];var Q=new GIcon();Q.shadow="http://r.chatr.com.cn/image/iconshadow.png";Q.iconSize=new GSize(21,27);Q.shadowSize=new GSize(25,30);Q.iconAnchor=new GPoint(10,27);Q.infoWindowAnchor=new GPoint(15,0);function T(AE){var AF=new GIcon(Q);AF.image="http://r.chatr.com.cn/image/marker_"+AE+".png";return AF;}function s(AU){var AK=AU.y;var AV=AU.x;var AE={lat:"",lng:"",latlng:""};var AQ;var AJ;if(AK>0){AQ="N";}else{AQ="S";AK=AK*-1;}if(AV>0){AJ="E";}else{AJ="W";AV=AV*-1;}var AM=parseInt(AK,10);var AH=parseInt(AV,10);var AT=AK-AM;var AP=AV-AH;var AL=60*AT;var AG=60*AP;var AF=parseInt(AL,10);var AS=parseInt(AG,10);var AO=AL-AF;var AI=AG-AS;var AR=parseFloat(60*AO).toFixed(2);var AN=parseFloat(60*AI).toFixed(2);AE.lat=[AM,"°",AF,"'",AR,'"',AQ].join("");AE.lng=[AH,"°",AS,"'",AN,'"',AJ].join("");AE.latlng=[AE.lat,AE.lng].join("");return AE;}function S(){}S.prototype=new GControl();S.prototype.initialize=function(AG){var AE=document.createElement("div");var AF=document.createElement("div");AF.id="pMapbutton";AF.title="看看都去过哪里";AF.selected=false;this.setButtonStyle(AE,AF);AE.appendChild(AF);AF.appendChild(document.createTextNode(V));GEvent.addDomListener(AF,"click",function(AH){if(j.havebeenCallback!==null){j.havebeenCallback.apply(AH);}});AG.getContainer().appendChild(AE);return AE;};S.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));};function b(){}b.prototype=new GControl();b.prototype.initialize=function(AG){var AE=document.createElement("div");var AF=document.createElement("div");AF.id="zFitbutton";AF.title="自动缩放，显示出全部标记";AF.selected=false;this.setButtonStyle(AE,AF);AE.appendChild(AF);AF.appendChild(document.createTextNode("全部标记"));GEvent.addDomListener(AF,"click",function(AH){AG.closeInfoWindow();AG.centerAndZoomOnBounds(AG,d);});AG.getContainer().appendChild(AE);return AE;};b.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(75,10));};function E(){}E.prototype=new GControl();E.prototype.initialize=function(AF){var AE=document.createElement("div");var AG=document.createElement("div");AG.id="markbutton";AG.title="在地图中放置标记";AG.selected=false;this.setButtonStyle(AE,AG);AE.appendChild(AG);AG.appendChild(document.createTextNode("添加标记"));GEvent.addDomListener(AG,"click",function(AH){AA(false);j.markbtnCallback.apply();t(AH);YUD.get("polybtncon").style.display="block";});AF.getContainer().appendChild(AE);return AE;};E.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));};function w(){}w.prototype=new GControl();w.prototype.initialize=function(AG){var AE=document.createElement("div");AE.id="polybtncon";AE.style.display="none";var AF=document.createElement("div");AF.id="polylinebutton";AF.title="在地图中标记折线";AF.selected=false;this.setButtonStyle(AE,AF);AE.appendChild(AF);AF.appendChild(document.createTextNode("补充路线"));GEvent.addDomListener(AF,"click",function(AH){l(AH);});AG.getContainer().appendChild(AE);return AE;};w.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));};function e(){}e.prototype=new GMenuMapTypeControl();e.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));};function N(){}N.prototype=new GControl();N.prototype.initialize=function(AF){var AE=document.createElement("div");var AG=document.createElement("div");AG.id="BigMapbutton";AG.title="查看大地图";AG.selected=false;this.setButtonStyle(AE,AG);AE.appendChild(AG);AG.appendChild(document.createTextNode(D));GEvent.addDomListener(AG,"click",function(AH){if(j.bigmapCallback!==null){j.bigmapCallback.apply(AH);}});AF.getContainer().appendChild(AE);return AE;};N.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));};var F=function(AE,AF){AE.style.color="#000000";AE.style.backgroundColor="white";AE.style.border="1px solid black";AE.style.padding="0px";AE.style.marginBottom="3px";AE.style.textAlign="center";AE.style.width="60px";AE.style.cursor="pointer";AE.style.position="absolute";AE.style.fontSize="12px";AE.style.fontFamily="Arial";AF.style.borderRight="1px solid #B0B0B0";AF.style.borderBottom="1px solid #B0B0B0";AF.style.borderTop="1px solid #FFFFFF";AF.style.borderLeft="1px solid #FFFFFF";AF.style.fontSize="12px";AF.style.fontFamily="Arial";};S.prototype.setButtonStyle=F;b.prototype.setButtonStyle=F;E.prototype.setButtonStyle=F;N.prototype.setButtonStyle=F;w.prototype.setButtonStyle=F;function a(AF){var AE;switch(u){case 0:AE=new GSize(10,10);break;case 1:AE=new GSize(75,10);break;case 2:AE=new GSize(140,10);break;case 3:AE=new GSize(215,10);break;}return AE;}if(new GBrowserIsCompatible()){var Z=new GMap2(document.getElementById(this.mapcontainer),{backgroundColor:"#99B3CC"});Z.addMapType(G_PHYSICAL_MAP);Z.enableContinuousZoom();Z.enableRotation();Z.enableDoubleClickZoom();Z.enableScrollWheelZoom();Z.setCenter(new GLatLng(32.5,106),3);Z.addControl(new GLargeMapControl3D());if(AB){var p=new GOverviewMapControl();Z.addControl(p);if(h){p.hide();}}var u=0;if(q){var M=a(u);Z.addControl(new E(),new GControlPosition(G_ANCHOR_TOP_RIGHT,M));u++;var W=a(u);Z.addControl(new w(),new GControlPosition(G_ANCHOR_TOP_RIGHT,W));u++;var g=new GClientGeocoder();var H=function(AE){YUE.preventDefault(AE);if(trim(YUD.get("LocalInput").value)!==""){YUD.get("localsearchloading").style.display="inline";if(g){g.getLocations(YUD.get("LocalInput").value,function(AF){if(AF&&AF.Status.code==200&&AF.Placemark.length>0){var AH="<ul>";for(L=0;L<AF.Placemark.length;L++){AH=[AH,'<li id="LreItem',L,'">&bull;&nbsp;<a href="#" rel="',AF.Placemark[L].Point.coordinates[1],"|",AF.Placemark[L].Point.coordinates[0],'">',AF.Placemark[L].address,"</a></li>"].join("");}AH=[AH,"</ul>"].join("");YUD.get("Localresults").innerHTML=AH;var AG=function(AJ){YUE.preventDefault(AJ);var AK=YUE.getTarget(AJ).rel.split("|");var AI=["<div class='LocalPointInfo'>",YUE.getTarget(AJ).innerHTML,"</div>"].join("");Z.setCenter(new GLatLng(AK[0],AK[1]),13);};for(m=0;m<AF.Placemark.length;m++){YUE.addListener("LreItem"+m,"click",AG);}}else{YUD.get("Localresults").innerHTML="<span class='noresults'>对不起，没有结果</span>";}YUD.get("localsearchloading").style.display="none";});}}else{}};YUE.addListener(YUD.get("LocalSearchform"),"submit",H);}else{if(V){var J=a(u);Z.addControl(new S(),new GControlPosition(G_ANCHOR_TOP_RIGHT,J));u++;}}if(A&&A.markers.length>1){var y=a(u);Z.addControl(new b(),new GControlPosition(G_ANCHOR_TOP_RIGHT,y));u++;}if(D){var R=a(u);Z.addControl(new N(),new GControlPosition(G_ANCHOR_TOP_RIGHT,R));u++;}if(r){var K=a(u);Z.addControl(new e(),new GControlPosition(G_ANCHOR_TOP_RIGHT,K));}}function AA(AF){var AE=YUD.get("polylinebutton");if(AF){X=1;AE.style.borderRight="1px solid #FFFFFF";AE.style.borderBottom="1px solid #FFFFFF";AE.style.borderTop="1px solid #B0B0B0";AE.style.borderLeft="1px solid #B0B0B0";AE.style.backgroundColor="#fff";AE.style.color="#000";Z.getDragObject().setDraggableCursor("crosshair");}else{AE.style.borderRight="1px solid #B0B0B0";AE.style.borderBottom="1px solid #B0B0B0";AE.style.borderTop="1px solid #FFFFFF";AE.style.borderLeft="1px solid #FFFFFF";AE.style.backgroundColor="#fff";AE.style.color="#000";AE.style.fontWeight="normal";Z.getDragObject().setDraggableCursor("hand");X=0;}}function l(AF){var AE=AF.target;if(X===0){AA(true);}else{if(X==1){AA(false);}}}function AC(AG){C.innerHTML=AG.tooltip;C.style.display="block";if(typeof C.style.filter=="string"){C.style.filter="alpha(opacity:70)";}var AH=Z.getCurrentMapType().getProjection();var AF=AH.fromLatLngToPixel(Z.fromDivPixelToLatLng(new GPoint(0,0),true),Z.getZoom());var AK=AH.fromLatLngToPixel(AG.getLatLng(),Z.getZoom());var AI=AG.getIcon().iconAnchor;var AJ=AG.getIcon().iconSize.width+6;var AE=10;var AL=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(AK.x-AF.x-AI.x+AJ,AK.y-AF.y-AI.y-AE));AL.apply(C);}function k(AE){I.push(AE);var AJ=false;var AI=true;if(q==1){AJ=true;AI=false;}var AG=new GIcon();AG.image="http://r.chatr.com.cn/image/mm_20_red.png";AG.shadow="http://r.chatr.com.cn/image/mm_20_shadow.png";AG.iconSize=new GSize(12,20);AG.shadowSize=new GSize(22,20);AG.iconAnchor=new GPoint(6,20);var AH=I.length-1;var AF=new GMarker(AE,{icon:AG,draggable:AJ,hide:AI});AF.tooltip="点击移除，拖拽修改";GEvent.addListener(AF,"mouseover",function(){AC(AF);});GEvent.addListener(AF,"mouseout",function(){C.style.display="none";});z[AH]=AF;Z.addOverlay(z[AH]);z[AH].enableDragging();GEvent.addListener(AF,"dragend",function(){x();});GEvent.addListener(AF,"dragstart",function(){C.style.display="none";});GEvent.addListener(AF,"click",function(){for(n=0;n<z.length;n++){if(z[n]==AF){Z.removeOverlay(z[n]);z=new ArrayItmRemove(n,z);I=new ArrayItmRemove(n,I);break;}}C.style.display="none";x();});if(I.length>1){x();}}function x(){if(O){Z.removeOverlay(O);}var AF=[];for(var AE=0;AE<z.length;AE++){AF.push(z[AE].getPoint());}O=new GPolyline(AF,"#0000ff",2,0.5);Z.addOverlay(O);if(q==1){j.polymadeCallback.apply(this,[AF]);}}function t(AG){if(U&&GlogalmarkerArray.length>=U){alert(["标记数不能超过",U,"个"].join(""));return ;}f=1;B=0;if(f===1&&B===0){var AH={"label":""};var AF=G(Z.getCenter(),AH.label,0);GlogalmarkerArray.push(AF);Z.addOverlay(AF);B=1;var AE=AG.target;if(U&&GlogalmarkerArray.length>=U){AE.style.borderRight="1px solid #C9C7BA";AE.style.borderBottom="1px solid #C9C7BA";AE.style.borderTop="1px solid #C9C7BA";AE.style.borderLeft="1px solid #C9C7BA";AE.style.backgroundColor="#F5F4EA";AE.style.color="#C9C7BA";}else{AE.style.borderRight="1px solid #FFFFFF";AE.style.borderBottom="1px solid #FFFFFF";AE.style.borderTop="1px solid #B0B0B0";AE.style.borderLeft="1px solid #B0B0B0";AE.style.backgroundColor="#fff";AE.style.color="#000";}}}GEvent.addListener(Z,"mousemove",function(AG){var AF=Z.getZoom();var AH=G_NORMAL_MAP.getProjection();var AE=AH.fromLatLngToPixel(AG,AF);i=AG;if(f==1){GlogalmarkerArray[GlogalmarkerArray.length-1].setPoint(AG);}});function o(AI,AG){var AU=AI.getLatLng();var AN=s(AU).lat;var AJ=s(AU).lng;var AW=AI.label;var AP=AI.owner;var AF=AI.date;var AR=AI.tags;var AT=AI.funclink;var AO=AI.img;var AM="",AH="",AE="",AS="",AK="",AV="",AL="";if(q==1){AM="<tr><td align='right'><b class='hue-btn'><button id='canclepoint' type='button' class='smaller'>删除</button></b></td></tr>";if(AG){j.markmadeCallback.apply(AI,[AU.lat(),AU.lng(),AU]);}}if(AW&&AW!==""&&q===0){AH=['<td width="185"><strong>地名:</strong>&nbsp;',AW,"<br>"].join("");}else{AH='<td width="185">';}if(AO){AL=["<tr><td valign='top'>",AO,"</td>"].join("");}else{AL="<tr>";}if(AP){AE=["<strong>作者:</strong>&nbsp;",AP,"<br>"].join("");}if(AF){AS=["<strong>日期:</strong>&nbsp;",AF,"<br>"].join("");}if(AR){AK=["<strong>标签:</strong>&nbsp;",AR,"<br>"].join("");}if(AT){AV=["<strong>",AT,"</strong></td></tr>"].join("");}var AQ="";if(q==1){AQ=["<table class='mapinfowin'>",AL,AH,"<strong>经度:</strong>&nbsp;",AJ,"&nbsp;<br/><strong>纬度:</strong>&nbsp;",AN,AE,AS,AK,AV,AM,"</td> </tr>"].join("");AI.openInfoWindow(AQ,{maxWidth:330});}else{AQ=["<table class='mapinfowin'>",AL,AH,AE,AS,AK,AV,AM,"</td> </tr>"].join("");AI.openInfoWindow(AQ,{maxWidth:330});}}function Y(AF){Z.removeOverlay(AF);GlogalmarkerArray=new ArrayItmRemove(AF.id,GlogalmarkerArray);j.markremoveCallback.apply(this);j.activeMarker=null;var AE=YUD.get("markbutton");AE.style.borderRight="1px solid #B0B0B0";AE.style.borderBottom="1px solid #B0B0B0";AE.style.borderTop="1px solid #FFFFFF";AE.style.borderLeft="1px solid #FFFFFF";AE.style.backgroundColor="#fff";AE.style.color="#000";AE.style.fontWeight="normal";}GEvent.addListener(Z,"click",function(AH,AF){if(q==1){if(f==1){var AE=document.getElementById("markbutton");AE.style.borderRight="1px solid #B0B0B0";AE.style.borderBottom="1px solid #B0B0B0";AE.style.borderTop="1px solid #FFFFFF";AE.style.borderLeft="1px solid #FFFFFF";AE.style.fontWeight="normal";var AI=GlogalmarkerArray[GlogalmarkerArray.length-1];o(AI,true);f=0;}else{if(X==1){if(!AH){var AG=new GLatLng(AF.lat(),AF.lng());k(AG);}}}}});function G(AE,AI,AH){var AG=(AI.label&&AI.label!=="")?AI.label:"";var AF=new GMarker(AE,{icon:T(AH),draggable:q,bounceGravity:0.9});AF.id=GlogalmarkerArray.length;AF.label=AG;AF.owner=AI.owner;AF.date=AI.date;AF.tags=AI.tags;AF.img=AI.img;AF.funclink=AI.funclink;GEvent.addListener(AF,"dragstart",function(){Z.closeInfoWindow();});GEvent.addListener(AF,"dragend",function(){o(AF,true);});GEvent.addListener(AF,"click",function(){j.activeMarker=AF;o(AF);});GEvent.addListener(AF,"infowindowopen",function(){if(q==1){GEvent.addDomListener(document.getElementById("canclepoint"),"click",function(){Y(AF);YUD.get("polybtncon").style.display="none";});j.activeMarker=AF;}});return AF;}this.setActiveMarker=function(AJ,AG,AI){var AH=new GLatLng(AG,AJ);var AF={"label":""};if(j.activeMarker){j.activeMarker.setLatLng(AH);Z.setCenter(AH);o(j.activeMarker,true);}else{if(U&&GlogalmarkerArray.length>=U){alert(["标记数不能超过",U,"个"].join(""));return ;}AF.label=AI;var AE=G(AH,AF,0);GlogalmarkerArray.push(AE);j.activeMarker=AE;Z.addOverlay(AE);o(AE,true);Z.setCenter(AH);}};this.mapobj=Z;this.ini=function(){if(A){var AJ=A;for(var AI=0;AI<AJ.markers.length;AI++){var AF=new GLatLng(AJ.markers[AI].lat,AJ.markers[AI].lng);var AG=G(AF,AJ.markers[AI],AI);d.extend(AF);Z.addOverlay(AG);GlogalmarkerArray.push(AG);if(AJ.markers[AI].oifw){o(AG);if(q==1){YUD.get("polybtncon").style.display="block";}}}Z.centerAndZoomOnBounds(Z,d);}var AE=YUD.get("markbutton");if(U&&GlogalmarkerArray.length>=U){AE.style.borderRight="1px solid #C9C7BA";AE.style.borderBottom="1px solid #C9C7BA";AE.style.borderTop="1px solid #C9C7BA";AE.style.borderLeft="1px solid #C9C7BA";AE.style.backgroundColor="#F5F4EA";AE.style.color="#C9C7BA";}if(q==1){C=document.createElement("div");C.className="polytooltip";C.style.display="none";Z.getPane(G_MAP_MARKER_PANE).appendChild(C);}if(c){var AH=[];for(AI=0;AI<c.points.length;AI++){var AK=GLatLng.fromUrlValue(c.points[AI].latlng);k(AK);d.extend(AK);}Z.centerAndZoomOnBounds(Z,d);}YUE.on(window,"unload",GUnload);};};