function ForDight($,_)
{$=Math.round($*Math.pow(10,_))/Math.pow(10,_);return $}

function getWindowHeight()
{if(window.self&&self.innerHeight)
return self.innerHeight;
if(document.documentElement&&document.documentElement.clientHeight)
return document.documentElement.clientHeight;

return 0}

function mapresize()
{th=getWindowHeight()-130;
document.getElementById("map").style.height=th+"px"}

function makeurl($)
{var _=Math.round(tx*100000)/100000,A=Math.round(ty*100000)/100000,B=$+"?x="+_+"&y="+A+"&zoom="+map.getZoom();return B}

function getmapurl(){var $=makeurl("http://www.snmap.com/"),_="<div style=\"width:333px; word-break:break-all;\"><strong>リンクをアクセス：<br /><a href=\""+$+"\">"+$+"</a><br /><br />以上のリンクをアクセスと、気楽に友達とこの地図を分かち合うことができます。</strong><br /></div><br />";map.openInfoWindowHtml(map.getCenter(),_)}

function addfav()
{var $=makeurl("http://www.snmap.com/");window.external.AddFavorite($,"Snmap マップ - 地図検索")}

function gotowide(){var $=makeurl("http://www.snmap.com/");top.location=$}

function flyto(B,A,_,$)
{if($>0)map.setCenter(new GLatLng(A,B),$);else map.setCenter(new GLatLng(A,B));map.openInfoWindowHtml(map.getCenter(),_)}

function totop()
{window.scrollTo(0,0)}

function gotoxy(){var _=document.xyform.x.value,$=document.xyform.y.value,A="経度："+_+"<br /><br />"+"緯度："+$;flyto(_,$,A,14);totop()}

function gotove()
{var $=makeurl("http://www.snmap.com/");top.location=$}



window.onresize=function(){mapresize()};
if(top.location!=self.location)
top.location=self.location;

function PanoramioLayerCallback(_,B)
{this.panoLayer=B;var A=[];for(var D=0;D<_.photos.length;D++){var C=_.photos[D];if(!B.ids[C.photo_id]){var $=this.createMarker(C,B.markerIcon);B.mgr.addMarker($,0);B.ids[C.photo_id]="exists"}}B.mgr.addMarkers(A,B.map.getZoom());B.mgr.refresh()}

PanoramioLayerCallback.prototype.formImgUrl=function(_,$){return"http://www.panoramio.com/photos/"+$+"/"+_+".jpg"};

PanoramioLayerCallback.prototype.formPageUrl=function($){return"http://www.panoramio.com/photo/"+$};

PanoramioLayerCallback.prototype.createMarker=function(D,C){var A=this,B=new GIcon(C);B.image=this.formImgUrl(D.photo_id,"mini_square");var $=new GMarker(new GLatLng(D.latitude,D.longitude),{icon:B,title:D.photo_title});if(D.photo_title.length>33)D.photo_title=D.photo_title.substring(0,33)+"&#8230;";var _="<div id='infowin' style='width:500px; height:390px;'>"+"<p><strong>"+D.photo_title+"</strong><br />投稿:<a target='_blank' href='"+D.owner_url+"'>"+D.owner_name+"</a></p>"+"<img border='0' width='500px' src='"+D.photo_file_url+"'/></a>"+"</div>";$.html=_;GEvent.addListener($,"click",function(){A.panoLayer.map.openInfoWindow($.getLatLng(),$.html,{noCloseOnClick:true})});return $};

function PanoramioLayer(A,_){var B=this;B.map=A;B.ids={};B.mgr=new MarkerManager(A,{maxZoom:19});var $=new GIcon();$.image="http://www.panoramio.com/img/panoramio-marker.png";$.shadow="";$.iconSize=new GSize(24,24);$.shadowSize=new GSize(22,22);$.iconAnchor=new GPoint(9,9);$.infoWindowAnchor=new GPoint(9,0);B.markerIcon=$;B.enabled=false;GEvent.addListener(A,"moveend",function(){if(B.enabled){var $=A.getBounds(),_=$.getSouthWest(),C=$.getNorthEast();B.load(B,{maxy:C.lat(),miny:_.lat(),maxx:C.lng(),minx:_.lng()})}})}

PanoramioLayer.prototype.enable=function(){this.enabled=true;GEvent.trigger(map,"moveend")};
PanoramioLayer.prototype.disable=function(){this.enabled=false;this.mgr.clearMarkers();this.ids={}};
PanoramioLayer.prototype.getEnabled=function(){return this.enabled};

PanoramioLayer.prototype.load=function(panoLayer,userOptions){var options={order:"popularity",set:"public",from:"0",to:"10",minx:"-180",miny:"-90",maxx:"180",maxy:"90",size:"medium"};for(optionName in userOptions)if(userOptions.hasOwnProperty(optionName))options[optionName]=userOptions[optionName];var url="http://www.panoramio.com/map/get_panoramas.php?",uniqueID="";for(optionName in options)if(options.hasOwnProperty(optionName)){var optionVal=""+options[optionName]+"";url+=optionName+"="+optionVal+"&";uniqueID+=optionVal.replace(/[^\w]+/g,"")}var callbackName="PanoramioLayerCallback.loader"+uniqueID;eval(callbackName+" = function(json) { var pa = new PanoramioLayerCallback(json, panoLayer);}");var script=document.createElement("script");script.setAttribute("src",url+"callback="+callbackName);script.setAttribute("id","jsonScript");script.setAttribute("type","text/javascript");document.documentElement.firstChild.appendChild(script)};

var distmks=[],distlines=null,mapjob,rdiv,ispano;

function drawdist()
{if(distlines){map.removeOverlay(distlines);distlines=null}if(distmks.length>1){var $=[],C=0;for(var D=0;D<distmks.length;D++){var _=distmks[D].getPoint();$.push(_);if(D>0){b=distmks[D-1].getPoint();var A=distab(b.lng(),b.lat(),_.lng(),_.lat());C=C+A}}distlines=new GPolyline($);map.addOverlay(distlines);var B="";if(C>1000)B="当面距離:"+ForDight(C/1000,3)+"キロメートル";else B="当面距離:"+ForDight(C,0)+"メートル";cjout(B)}else if(distmks.length==1)cjout("終了を選んでください")}

function distab(C,G,E,$){var F=G*Math.PI/180,_=$*Math.PI/180,D=F-_,A=C*Math.PI/180-E*Math.PI/180,B=2*Math.asin(Math.sqrt(Math.pow(Math.sin(D/2),2)+Math.cos(F)*Math.cos(_)*Math.pow(Math.sin(A/2),2)));B=B*6378137;B=Math.round(B*10000)/10000;return B}

function getdis(A){if(mapjob=="distance"){if(distlines){map.removeOverlay(distlines);distlines=null}for(var _=distmks.length-1;_>=0;_--)map.removeOverlay(distmks[_]);distmks=[];if(A!=1){cjout("",1);mapjob=""}else cjout("最初を選んでください")}else{var $="<div style=\"width:339px; word-break:break-all;\">距離測りを起動しましたー”始まり”をクリックして、距離測りを開始します<br /><br />二つ、二つ以上の場所の距離を測れる、測った結果は地図の右下で表示します。</div><br />";map.openInfoWindowHtml(map.getCenter(),$);cjout("最初を選んでください");mapjob="distance"}}

function mapclick($,A){if(mapjob=="distance"&&A!=null){var _=new GMarker(A,{draggable:true});distmks.push(_);map.addOverlay(_);GEvent.addListener(_,"dragend",function(){drawdist()});drawdist()}}

function cjout($,A){if(map){if(rdiv==null){rdiv=document.createElement("div");rdiv.style.position="absolute";map.getContainer().appendChild(rdiv)}if(A!=1){var _="<br /><a href=\"javascript:void(0)\" onclick=\"return getdis(1)\" title=\"リセット\">	リセット</a> <a href=\"javascript:void(0)\" onclick=\"return getdis()\" title=\"中止测量\">测量終わり</a>";rdiv.innerHTML="<span class=\"distance\">"+$+_+"</span>"}else rdiv.innerHTML=$;rdiv.style.left=(map.getSize().width-200)+"px";rdiv.style.top=(30)+"px"}}

function showpano(){var $=document.getElementById("spbtn");if(ispano==1){panoLayer.disable();ispano=0;if($)$.innerHTML="写真"}else{if(typeof(panoLayer)!="undefined")panoLayer.enable();else{panoLayer=new PanoramioLayer(map);panoLayer.enable()}ispano=1;if($)$.innerHTML="隠す写真"}}

function MarkerManager(A,_){var B=this;B.map_=A;B.mapZoom_=A.getZoom();B.projection_=A.getCurrentMapType().getProjection();_=_||{};B.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var $=MarkerManager.DEFAULT_MAX_ZOOM_;if(_.maxZoom!=undefined)$=_.maxZoom;B.maxZoom_=$;B.trackMarkers_=_.trackMarkers;var C;if(typeof _.borderPadding=="number")C=_.borderPadding;else C=MarkerManager.DEFAULT_BORDER_PADDING_;B.swPadding_=new GSize(-C,C);B.nePadding_=new GSize(C,-C);B.borderPadding_=C;B.gridWidth_=[];B.grid_=[];B.grid_[$]=[];B.numMarkers_=[];B.numMarkers_[$]=0;GEvent.bind(A,"moveend",B,B.onMapMoveEnd_);B.removeOverlay_=function($){A.removeOverlay($);B.shownMarkers_--};B.addOverlay_=function($){A.addOverlay($);B.shownMarkers_++};B.resetManager_();B.shownMarkers_=0;B.shownBounds_=B.getMapGridBounds_()}

MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_MAX_ZOOM_=17;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;

MarkerManager.prototype.resetManager_=function(){var A=this,$=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var _=0;_<=A.maxZoom_;++_){A.grid_[_]=[];A.numMarkers_[_]=0;A.gridWidth_[_]=Math.ceil($/A.tileSize_);$<<=1}};

MarkerManager.prototype.clearMarkers=function(){var $=this;$.processAll_($.shownBounds_,$.removeOverlay_);$.resetManager_()};

MarkerManager.prototype.getTilePoint_=function(A,$,B){var _=this.projection_.fromLatLngToPixel(A,$);return new GPoint(Math.floor((_.x+B.width)/this.tileSize_),Math.floor((_.y+B.height)/this.tileSize_))};

MarkerManager.prototype.addMarkerBatch_=function(A,E,_){var $=A.getPoint();if(this.trackMarkers_)GEvent.bind(A,"changed",this,this.onMarkerMoved_);var C=this.getTilePoint_($,_,GSize.ZERO);for(var B=_;B>=E;B--){var D=this.getGridCellCreate_(C.x,C.y,B);D.push(A);C.x=C.x>>1;C.y=C.y>>1}};

MarkerManager.prototype.isGridPointVisible_=function(_){var C=this,$=C.shownBounds_.minY<=_.y&&_.y<=C.shownBounds_.maxY,D=C.shownBounds_.minX,A=D<=_.x&&_.x<=C.shownBounds_.maxX;if(!A&&D<0){var B=C.gridWidth_[C.shownBounds_.z];A=D+B<=_.x&&_.x<=B-1}return $&&A};

MarkerManager.prototype.onMarkerMoved_=function(A,$,E){var D=this,B=D.maxZoom_,G=false,_=D.getTilePoint_($,B,GSize.ZERO),F=D.getTilePoint_(E,B,GSize.ZERO);while(B>=0&&(_.x!=F.x||_.y!=F.y)){var C=D.getGridCellNoCreate_(_.x,_.y,B);if(C)if(D.removeFromArray(C,A))D.getGridCellCreate_(F.x,F.y,B).push(A);if(B==D.mapZoom_)if(D.isGridPointVisible_(_)){if(!D.isGridPointVisible_(F)){D.removeOverlay_(A);G=true}}else if(D.isGridPointVisible_(F)){D.addOverlay_(A);G=true}_.x=_.x>>1;_.y=_.y>>1;F.x=F.x>>1;F.y=F.y>>1;--B}if(G)D.notifyListeners_()};

MarkerManager.prototype.removeMarker=function(_){var D=this,A=D.maxZoom_,E=false,$=_.getPoint(),C=D.getTilePoint_($,A,GSize.ZERO);while(A>=0){var B=D.getGridCellNoCreate_(C.x,C.y,A);if(B)D.removeFromArray(B,_);if(A==D.mapZoom_)if(D.isGridPointVisible_(C)){D.removeOverlay_(_);E=true}C.x=C.x>>1;C.y=C.y>>1;--A}if(E)D.notifyListeners_()};

MarkerManager.prototype.addMarkers=function(_,A,C){var $=this.getOptMaxZoom_(C);for(var B=_.length-1;B>=0;B--)this.addMarkerBatch_(_[B],A,$);this.numMarkers_[A]+=_.length};

MarkerManager.prototype.getOptMaxZoom_=function($){return $!=undefined?$:this.maxZoom_};

MarkerManager.prototype.getMarkerCount=function(_){var $=0;for(var A=0;A<=_;A++)$+=this.numMarkers_[A];return $};

MarkerManager.prototype.addMarker=function(_,B,D){var C=this,$=this.getOptMaxZoom_(D);C.addMarkerBatch_(_,B,$);var A=C.getTilePoint_(_.getPoint(),C.mapZoom_,GSize.ZERO);if(C.isGridPointVisible_(A)&&B<=C.shownBounds_.z&&C.shownBounds_.z<=$){C.addOverlay_(_);C.notifyListeners_()}this.numMarkers_[B]++};

GBounds.prototype.containsPoint=function($){var _=this;return(_.minX<=$.x&&_.maxX>=$.x&&_.minY<=$.y&&_.maxY>=$.y)};

MarkerManager.prototype.getGridCellCreate_=function(D,C,B){var _=this.grid_[B];if(D<0)D+=this.gridWidth_[B];var A=_[D];if(!A){A=_[D]=[];return A[C]=[]}var $=A[C];if(!$)return A[C]=[];return $};

MarkerManager.prototype.getGridCellNoCreate_=function(C,B,A){var $=this.grid_[A];if(C<0)C+=this.gridWidth_[A];var _=$[C];return _?_[B]:undefined};

MarkerManager.prototype.getGridBounds_=function($,E,_,G){E=Math.min(E,this.maxZoom_);var D=$.getSouthWest(),B=$.getNorthEast(),H=this.getTilePoint_(D,E,_),F=this.getTilePoint_(B,E,G),C=this.gridWidth_[E];if(B.lng()<D.lng()||F.x<H.x)H.x-=C;if(F.x-H.x+1>=C){H.x=0;F.x=C-1}var A=new GBounds([H,F]);A.z=E;return A};

MarkerManager.prototype.getMapGridBounds_=function(){var $=this;return $.getGridBounds_($.map_.getBounds(),$.mapZoom_,$.swPadding_,$.nePadding_)};

MarkerManager.prototype.onMapMoveEnd_=function(){var $=this;$.objectSetTimeout_(this,this.updateMarkers_,0)};MarkerManager.prototype.objectSetTimeout_=function(_,$,A){return window.setTimeout(function(){$.call(_)},A)};

MarkerManager.prototype.refresh=function(){var $=this;if($.shownMarkers_>0)$.processAll_($.shownBounds_,$.removeOverlay_);$.processAll_($.shownBounds_,$.addOverlay_);$.notifyListeners_()};

MarkerManager.prototype.updateMarkers_=function(){var $=this;$.mapZoom_=this.map_.getZoom();var _=$.getMapGridBounds_();if(_.equals($.shownBounds_)&&_.z==$.shownBounds_.z)return;if(_.z!=$.shownBounds_.z){$.processAll_($.shownBounds_,$.removeOverlay_);$.processAll_(_,$.addOverlay_)}else{$.rectangleDiff_($.shownBounds_,_,$.removeCellMarkers_);$.rectangleDiff_(_,$.shownBounds_,$.addCellMarkers_)}$.shownBounds_=_;$.notifyListeners_()};

MarkerManager.prototype.notifyListeners_=function(){GEvent.trigger(this,"changed",this.shownBounds_,this.shownMarkers_)};

MarkerManager.prototype.processAll_=function($,_){for(var B=$.minX;B<=$.maxX;B++)for(var A=$.minY;A<=$.maxY;A++)this.processCellMarkers_(B,A,$.z,_)};

MarkerManager.prototype.processCellMarkers_=function(D,B,A,_){var $=this.getGridCellNoCreate_(D,B,A);if($)for(var C=$.length-1;C>=0;C--)_($[C])};

MarkerManager.prototype.removeCellMarkers_=function(A,_,$){this.processCellMarkers_(A,_,$,this.removeOverlay_)};

MarkerManager.prototype.addCellMarkers_=function(A,_,$){this.processCellMarkers_(A,_,$,this.addOverlay_)};

MarkerManager.prototype.rectangleDiff_=function($,_,A){var B=this;B.rectangleDiffCoords($,_,function(C,_){A.apply(B,[C,_,$.z])})};

MarkerManager.prototype.rectangleDiffCoords=function($,_,I){var D=$.minX,B=$.minY,F=$.maxX,H=$.maxY,C=_.minX,A=_.minY,E=_.maxX,G=_.maxY;for(var K=D;K<=F;K++){for(var J=B;J<=H&&J<A;J++)I(K,J);for(J=Math.max(G+1,B);J<=H;J++)I(K,J)}for(J=Math.max(B,A);J<=Math.min(H,G);J++){for(K=Math.min(F+1,C)-1;K>=D;K--)I(K,J);for(K=Math.max(D,E+1);K<=F;K++)I(K,J)}};
MarkerManager.prototype.removeFromArray=function(C,$,_){var A=0;for(var B=0;B<C.length;++B)if(C[B]===$||(_&&C[B]==$)){C.splice(B--,1);A++}return A}


