⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maps_editing.js

📁 一款基于PHP的网络日记程序。WikyBlog支持:多用户的 BLOG
💻 JS
字号:
mapEditing=true;var lstWrn=false;var miles=true;function showSaveBox(a,i){i=i||1;var box=p.dcg('WBmapEdit'+a);var c=box.childNodes;for(var j=0;j<c.length;j++){if(c[j].style){c[j].style.display='none';}}box=p.dcg('WBmapEdit'+i+a);box.style.display='';return;}function emptyListeners(){if(mapObj.listeners.length>0){for(var j=0;j<mapObj.listeners.length;j++){GEvent.removeListener(mapObj.listeners[j]);}mapObj.listeners=Array();}	}function redrawLine(i){if(mapObj.overlays[i]){myGmap.removeOverlay(mapObj.overlays[i]);}mapObj.overlays[i]=new GPolyline(mapObj.cl,'#0000ff');myGmap.addOverlay(mapObj.overlays[i]);if(i==mapObj.current){pLineDist();}}function setInfo(){var i=mapObj.current;if(!mapObj.overlays[i])return;var pt=mapObj.overlays[i].getPoint();txt=lg[8]+reduce(pt.lat(),4);txt+='     '+lg[7]+reduce(pt.lng(),4);var dv=p.dcg('WBmapFld'+p.shwn+i);dv=dv.previousSibling;var fld='WBmapFld'+p.shwn;if(dv){id=dv.id.substr(fld.length);var ol=mapObj.overlays[id];if(ol){var pt2=false;if(ol.getPoint){pt2=ol.getPoint();}else if(ol.getVertex){pt2=ol.getVertex(ol.getVertexCount()-1);}if(pt2){txt+='     '+lg[47]+reduce(myDist(pt,pt2))+getUnits();}}}if(p.shwnF.mapInfo)p.shwnF.mapInfo.value=txt;}function editOverlay(i,tmp,desc){emptyListeners();if(i>=0){var desc=p.dcg('WBmapDesc'+p.shwn+i).value;tmp='';if(mapObj.overlays[i]){if(mapObj.cl)delete mapObj.cl;if(!mapObj.overlays[i].setPoint){tmp+='<a href="javascript:void(0)" onclick="mf.pLineUndo()">'+lg[13]+'</a> ';editPLine(i);}else{tmp+='<a href="javascript:void(0)" onclick="mf.moveMarker()">'+lg[44]+'</a> ';setInfo();}}tmp+='<a href="javascript:void(0)" onclick="mf.getInfo()" >'+lg[10]+'</a>';tmp+='<a href="javascript:void(0)" onclick="mf.moveUp()" >'+lg[11]+'</a>';tmp+='<a href="javascript:void(0)" onclick="mf.moveDown()">'+lg[12]+'</a>';tmp+='<a href="javascript:void(0)" onclick="mf.olayRemove()">'+lg[14]+'</a>';}if(p.shwnF.description)p.shwnF.description.value=desc;setTimeout(function(){p.dcg('WBmapRepl'+p.shwn).innerHTML=tmp;},10);}function editPLine(i){this.tDist='here';mapObj.cl=pLineToPoints(mapObj.overlays[i]);pLineDist();pLineInfo(i);l=GEvent.addListener(myGmap,'click',function(ol,pt){mapObj.cl.push(pt);redrawLine(i);incrCount2(2);pLineInfo(i);p.wbEdit.set(true);});mapObj.listeners.push(l);l=GEvent.addListener(myGmap,'mousemove',function(pt){pLineInfo(i,pt);});mapObj.listeners.push(l);}function pLineInfo(i,pt){var j=mapObj.cl.length;var u=getUnits();txt='';txt+=lg[9]+(j);txt+='    '+lg[36]+mapObj.len+u;if(j>0){var pt1=mapObj.overlays[i].getVertex(j-1);if(pt){txt+='    '+lg[37]+reduce(myDist(pt,pt1))+u;}}if(p.shwnF.mapInfo)p.shwnF.mapInfo.value=txt;}function pLineDist(){if(!mapObj.cl)return;var ppt;var dis=0;var leg=0;for(var j=0;j<mapObj.cl.length;j++){if(ppt){dis=dis+myDist(ppt,mapObj.cl[j]);;}ppt=mapObj.cl[j];}mapObj.len=reduce(dis);}function newPline(){unSelectCur();var tmp=lg[19];tmp2=lg[20];editOverlay(-1,tmp,tmp2);emptyListeners();l=GEvent.addListener(myGmap,'click',function(ol,pt){var i=mapObj.overlays.length;txt=p.shwnF.description.value;mapObj.cl=Array();mapObj.cl.push(pt);redrawLine(i);addMenu(i,txt);overlaySelect(i);incrCount2(2);});mapObj.listeners.push(l);if(p.shwnF.mapInfo)p.shwnF.mapInfo.value='';}function pLineUndo(){var i=mapObj.current;if(mapObj.overlays[i].setPoint){return;}if(mapObj.cl.length>0){mapObj.cl.pop();mapObj.count--;if(mapObj.cl.length>0){redrawLine(i);}pLineInfo(i);}}function newMarker(){emptyListeners();var x=myGmap.getCenter();i=newMarker2(x,2);myAddOverlay(i,lg[17]+i);overlaySelect(i);moveMarker();return;}function moveMarker(){myGmap.closeInfoWindow();var i=mapObj.current;if(!mapObj.overlays[i].setPoint){return;}p.wbEdit.set(true);l=GEvent.addListener(myGmap,'mousemove',function(pt){mapObj.overlays[i].setPoint(pt);setInfo();});mapObj.listeners.push(l);var x=mapObj.overlays[i].getPoint();l=GEvent.addListener(myGmap,'mouseout',function(a){mapObj.overlays[i].setPoint(x);});mapObj.listeners.push(l);l=GEvent.addListener(myGmap,'click',function(a,b){emptyListeners();});mapObj.listeners.push(l);}function olayRemove(){try{var i=mapObj.current;if(!(i>=0)){return;}p.wbEdit.set(true);myGmap.closeInfoWindow();myGmap.removeOverlay(mapObj.overlays[i]);var prev=getPrevId();if(mapObj.overlays[i].setPoint){mapObj.count--;}else{mapObj.count-=mapObj.overlays[i].getVertexCount();}if(i==(mapObj.overlays.length-1)){mapObj.overlays.splice(i,1);mapObj.letters.pop();}else{delete mapObj.overlays[i];}p.wbMaps.removeMenu(i);delete mapObj.current;overlaySelect(prev);return true;}catch(m){p.err(m,'remove');return true;}			}function moveDown(){var currentDiv=p.dcg('WBmapFld'+p.shwn+mapObj.current);var prnt=currentDiv.parentNode;var below=currentDiv.nextSibling;if(!below){currentDiv=prnt.removeChild(currentDiv);prnt.insertBefore(currentDiv,prnt.firstChild);}else{below=prnt.removeChild(below);prnt.insertBefore(below,currentDiv);p.wbEdit.set(true);}}function moveUp(){var currentDiv=p.dcg('WBmapFld'+p.shwn+mapObj.current);var prnt=currentDiv.parentNode;var above=currentDiv.previousSibling;currentDiv=prnt.removeChild(currentDiv);if(!above){prnt.appendChild(currentDiv);return;}prnt.insertBefore(currentDiv,above);p.wbEdit.set(true);}function updateDesc(){p.wbEdit.set(true);i=mapObj.current;if(!mapObj.overlays[i]){return;}var txt=p.shwnF.description.value;if(txt.length>1000){alert(p.sprintf(lg[23],txt.length));}var d=p.dcg('WBmapDesc'+p.shwn+i);if(d.value==txt){return;}if(mapObj.overlays[i]){d.value=txt;}var menu=p.dcg('WBmapFld'+p.shwn+i);if(menu){var str='';if(mapObj.letters[i]){str='<b>'+mapObj.letters[i]+'</b>'}str+=formatText(txt,20);menu.innerHTML=str;}overlaySelect(i);}function saveMap(url){if(!p.wbCompat){err('not wbCompat for map');return;}if(mapObj.count>maxPoints){alert(p.sprintf(lg[25],mapObj.count,maxPoints));return;}var a=p.dcg('WBinputs'+p.shwn);a.innerHTML='';var d=Array();var c=false;var txt;a.innerHTML+='<input type="hidden" name="zoom" value="'+myGmap.getZoom()+'" />';var mType=-1;for(var ix=0;ix<myGmap.getMapTypes().length;ix++){if(myGmap.getMapTypes()[ix]==myGmap.getCurrentMapType())mType=ix;}a.innerHTML+='<input type="hidden" name="mapType" value="'+mType+'" />';var olays=p.dcg('WBmarkers'+p.shwn).childNodes;if(!olays){return;}var fld='WBmapFld'+p.shwn;for(i=0;i<olays.length;i++){if(!olays[i].id){continue;}id=olays[i].id.substr(fld.length);if(mapObj.overlays[id].setPoint){a.innerHTML+='<input type="hidden" name="npts['+id+'][]" value="'+mapObj.overlays[id].getPoint().lat()+'" />';a.innerHTML+='<input type="hidden" name="npts['+id+'][]" value="'+mapObj.overlays[id].getPoint().lng()+'" />';if(!c){c=mapObj.overlays[id].getPoint();}}else{var len=mapObj.overlays[id].getVertexCount();for(var j=0;j<len;j++){var pt=mapObj.overlays[id].getVertex(j);if(pt){a.innerHTML+='<input type="hidden" name="npts['+id+']['+j+'][]" value="'+pt.lat()+'" />';a.innerHTML+='<input type="hidden" name="npts['+id+']['+j+'][]" value="'+pt.lng()+'" />';}}if(!c){c=mapObj.overlays[id].getVertex(0);}}}if(!c){c=myGmap.getCenter();}a.innerHTML+='<input type="hidden" name="c2[]" value="'+c.lat()+'" />';a.innerHTML+='<input type="hidden" name="c2[]" value="'+c.lng()+'" />';p.doHist=1;var tmp=p.shwnF.action;p.shwnF.action=p.wbXmlHttp.reqUrl(p.shwnF.action);p.shwnF.target="WBhistory";setTimeout(function(){p.resetAction(p.shwnF,tmp);},100);p.shwnF.submit();p.wbEdit.set(false);}function getInfo(){var i=mapObj.current;var tp;var m='';var cl='';var thPt;var pr=getPrevId();var n=getNextId();var pPt;var txt;m+='<div class="WBboxInfo">&nbsp;</div>';m+='<div class="WBcontentArea2">';m+='<h1 class="WBpageTitle">'+lg[27]+'</h1>';m+='<table class="tableRows" width="100%">';if(mapObj.overlays[i].setPoint){thPt=mapObj.overlays[i].getPoint();tp='Marker';m+='<tr><th>'+lg[28]+'</th><th>'+lg[29]+'</th></tr>';txt=p.dcg('WBmapDesc'+p.shwn+mapObj.current).value;m+='<tr><td>'+thPt+'</td><td>'+formatText(txt,35)+'</td></tr>';}else{tp='Route';thPt=mapObj.overlays[i].getVertex(0);var pts=pLineToPoints(mapObj.overlays[i]);var ppt;var nwDis=0;var dis=0;m+='<tr><th>'+lg[30]+'</th><th>'+lg[31]+'</th><th>'+lg[32]+'</th></tr>';for(var j=0;j<pts.length;j++){if(ppt){nwDis=myDist(ppt,pts[j]);dis=dis+nwDis;}cl=' class="tableRowOdd" ';if((j%2)==0){cl=' class="tableRowEven" ';}m+='<tr'+cl+'><td> '+(j+1)+' </td><td> '+reduce(nwDis)+getUnits()+'</td><td> '+pts[j]+' </td></tr>';ppt=pts[j];}m+='<tr><th>'+lg[33]+'</th><th>'+lg[34]+'</th><th>'+lg[35]+'</th></tr>';m+='<td>'+(pts.length-1)+'</td><td>'+reduce(dis)+getUnits()+'</td><td>'+reduce(myDist(ppt,pts[0]))+getUnits()+'</td></tr>';}if(pr !=i){if(mapObj.overlays[pr].setPoint){pPt=mapObj.overlays[pr].getPoint();}else{pPt=mapObj.overlays[pr].getVertex(0);}m+='<tr><th>'+lg[40]+'</th><th>'+lg[41]+'</th></tr>';txt=p.dcg('WBmapDesc'+p.shwn+pr).value;m+='<tr><td>'+reduce(myDist(thPt,pPt))+getUnits()+'</td><td>'+formatText(txt,35)+'</td></tr>';}if(n !=i){if(mapObj.overlays[n].setPoint){pPt=mapObj.overlays[n].getPoint();}else{pPt=mapObj.overlays[n].getVertex(0);}m+='<tr><th>'+lg[42]+'</th><th>'+lg[43]+'</th></tr>';txt=p.dcg('WBmapDesc'+p.shwn+n).value;m+='<tr><td>'+reduce(myDist(thPt,pPt))+getUnits()+'</td><td>'+formatText(txt,35)+'</td></tr>';}	m+='</table>';m+='<br/><div class="sm">';m+=lg[49];m+='</div><br/>';m+='</div>';txt=p.dcg('WBmapDesc'+p.shwn+i).value;p.at=false;var lbl=formatText(txt,16);var id=p.wbCA.add(lbl,m,false,false,false);p.tabBrowse.go(id);}function reduce(x,a){a=a||1;var b=Math.pow(10,a);return Math.round(x*b)/b;}function chUnits(){var a=p.dcg('WBunits'+p.shwn);if(miles){a.innerHTML=lg[39];miles=false;}else{a.innerHTML=lg[38];miles=true;}overlaySelect(mapObj.current);}function getUnits(){if(miles){return lg[38];}return lg[39];}function myDist(a,b){var c=a.distanceFrom(b);if(miles){return c/1609.344;}return c/1000;}function distance(y1,x1,y2,x2){var a=Math.sin(y1/57.2958)* Math.sin(y2/57.2958);var b=Math.cos(y1/57.2958)* Math.cos(y2/57.2958)*  Math.cos((x2/57.2958)-(x1/57.2958));return 3963.0 * Math.acos(a+b);}var gpxLoaded=false;function getGpx(){if(typeof(p.import_gpx)=='undefined'){p.wbMsgs.showB();p.loadFile('script','/include/'+p.jsNum+'/maps_gpx.js',true);setTimeout('getGpx()',300);return;}p.wbMsgs.closeA();var a=tabBrowse.getTabNode2('A',false,p.shwn);showSaveBox(a.rev,3);}editMap.init2=function(){mapSize.reSize();editOverlay(mapObj.current,'','');if(mapObj.count>(maxPoints-10)){if(mapObj.count>maxPoints){alert(p.sprintf(lg[3],mapObj.count,maxPoints));}else{alert(p.sprintf(lg[50],mapObj.count,maxPoints));}}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -