var map1Element=document.getElementById('map1');var map2Element=document.getElementById('map2');var htitleElement=document.getElementById('htitle');var vtitleElement=document.getElementById('vtitle');var haboutElement=document.getElementById('habout');var vaboutElement=document.getElementById('vabout');var aboutElement=null;var hlinkElement=document.getElementById('hlink');var vlinkElement=document.getElementById('vlink');var map1=null;var map2=null;var center1=null;var center2=null;function Setup() {try {acme.maps3.Initialize();Layout();window.onresize=Layout;var options={zoom:10,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:false,scaleControl:true};map1=new google.maps.Map(map1Element,options);map2=new google.maps.Map(map2Element,options);acme.maps3.ScrollWheelZoom(map1,document.documentElement);SavePositionsZoomTypesOnChanges();if(!GetPositionsZoomTypesQuery()) {if(!GetPositionsZoomTypesCookie()) {var point=acme.maps3.GetLatLngFromIP();var zoom=13;if(point==null) {point=new google.maps.LatLng(0.0,0.0);zoom=2;} map1.setCenter(point,zoom);map2.setCenter(point,zoom);}} center1=map1.getCenter();center2=map2.getCenter();google.maps.event.addListener(map1,'zoom_changed',acme.utils.MakeCaller(CopyZoom,map1,map2));google.maps.event.addListener(map2,'zoom_changed',acme.utils.MakeCaller(CopyZoom,map2,map1));google.maps.event.addListener(map1,'center_changed',acme.utils.MakeCaller(MoveEndHandler,map1));google.maps.event.addListener(map2,'center_changed',acme.utils.MakeCaller(MoveEndHandler,map2));google.maps.event.addListener(map1,'resize',acme.utils.MakeCaller(ResizeHandler,map1));google.maps.event.addListener(map2,'resize',acme.utils.MakeCaller(ResizeHandler,map2));} catch(e) {acme.utils.Log('Setup:\n'+acme.utils.Props(e));}} var copyingZoom=false;function CopyZoom(mapa,mapb) {if(!copyingZoom) {copyingZoom=true;mapb.setZoom(mapa.getZoom());copyingZoom=false;}} function MoveEndHandler(map) {if(map==map1) center1=map.getCenter();else center2=map.getCenter();} function ResizeHandler(map) {if(map==map1) map.setCenter(center1);else map.setCenter(center2);} function Layout() {var bodyWidth=document.documentElement.clientWidth;var bodyHeight=document.documentElement.clientHeight;if(bodyWidth>bodyHeight) {vtitleElement.style.display='';htitleElement.style.display='none';aboutElement=vaboutElement;var mapWidth=(bodyWidth-vtitleElement.clientWidth)/2;map1Element.style.top=map2Element.style.top='0';map1Element.style.bottom=map2Element.style.bottom='0';map1Element.style.left='0';map2Element.style.right='0';map1Element.style.right=map2Element.style.left='';map1Element.style.width=map2Element.style.width=mapWidth+'px';map1Element.style.height=map2Element.style.height=bodyHeight+'px';vtitleElement.style.left=mapWidth+'px';vtitleElement.style.top=(bodyHeight-vtitleElement.clientHeight)/2+'px';} else {htitleElement.style.display='';vtitleElement.style.display='none';aboutElement=haboutElement;var mapHeight=(bodyHeight-htitleElement.clientHeight)/2;map1Element.style.left=map2Element.style.left='0';map1Element.style.right=map2Element.style.right='0';map1Element.style.top='0';map2Element.style.bottom='0';map1Element.style.bottom=map2Element.style.top='';map1Element.style.height=map2Element.style.height=mapHeight+'px';map1Element.style.width=map2Element.style.width=bodyWidth+'px';htitleElement.style.top=mapHeight+'px';htitleElement.style.left=(bodyWidth-htitleElement.clientWidth)/2+'px';}} function PopUpAbout() {acme.utils.PopUpHtml(aboutElement,'\ The two maps on this page are constrained to be the same scale. If you zoom one map, the other map zooms the same way. This lets you visually compare two different areas. For example, here is a comparison of San Francisco and Paris.\ ',{right:'0px',top:'-3px',width:'270px',height:'130px',overflow:'auto',color:'#000000',backgroundColor:'#ffffff',border:'5px ridge #000000',padding:'10px',textAlign:'left'});} function Flip() {var zoom=map1.getZoom();var tCenter=center1;center1=center2;center2=tCenter;map1.setCenter(center1,zoom);map2.setCenter(center2,zoom);var tMapType=map1.getMapTypeId();map1.setMapTypeId(map2.getMapTypeId());map2.setMapTypeId(tMapType);} var pztCookieName='positionsZoomTypes';function SavePositionsZoomTypesOnChanges() {google.maps.event.addListener(map1,'center_changed',SavePositionsZoomTypes);google.maps.event.addListener(map2,'center_changed',SavePositionsZoomTypes);google.maps.event.addListener(map1,'zoom_changed',SavePositionsZoomTypes);google.maps.event.addListener(map2,'zoom_changed',SavePositionsZoomTypes);google.maps.event.addListener(map1,'maptypeid_changed',SavePositionsZoomTypes);google.maps.event.addListener(map2,'maptypeid_changed',SavePositionsZoomTypes);} function SavePositionsZoomTypes() {var stateStr=EncodeState();if(!stateStr) return;hlinkElement.href=vlinkElement.href=window.location.protocol+'//'+window.location.host+window.location.pathname+'?'+stateStr;acme.utils.SaveCookie(pztCookieName,stateStr);} function GetPositionsZoomTypesQuery() {var stateStr=window.location.search.substring(1,window.location.search.length);if(stateStr==null||stateStr=='') return false;return DecodeState(decodeURIComponent(stateStr));} function GetPositionsZoomTypesCookie() {var stateStr=acme.utils.GetCookie(pztCookieName);if(stateStr==null||stateStr=='') return false;return DecodeState(stateStr);} function EncodeState() {var map1Center=map1.getCenter();var map2Center=map2.getCenter();if(map1Center==null||map2Center==null) return null;var map1Y=map1Center.lat();var map1X=map1Center.lng();var map2Y=map2Center.lat();var map2X=map2Center.lng();var mapZoom=map1.getZoom();var map1TypeLetter=acme.maps3.MapTypeIdToLetter(map1.getMapTypeId());var map2TypeLetter=acme.maps3.MapTypeIdToLetter(map2.getMapTypeId());if(map1Y==NaN||map1X==NaN||map2Y==NaN||map2X==NaN||mapZoom==NaN||map1TypeLetter==null||map2TypeLetter==null) return null;return map1Y.toFixed(5)+','+map1X.toFixed(5)+','+map2Y.toFixed(5)+','+map2X.toFixed(5)+','+mapZoom+','+map1TypeLetter+','+map2TypeLetter;} function DecodeState(stateStr) {var vals=stateStr.split(',');if(vals.length!=7) return false;var map1Y=parseFloat(vals[0]);var map1X=parseFloat(vals[1]);var map2Y=parseFloat(vals[2]);var map2X=parseFloat(vals[3]);var mapZoom=parseInt(vals[4]);var map1Type=acme.maps3.LetterToMapTypeId(vals[5]);var map2Type=acme.maps3.LetterToMapTypeId(vals[6]);if(map1Y==NaN||map1X==NaN||map2Y==NaN||map2X==NaN||mapZoom==NaN||map1Type==null||map2Type==null) return false;map1.setCenter(new google.maps.LatLng(map1Y,map1X));map2.setCenter(new google.maps.LatLng(map2Y,map2X));map1.setZoom(mapZoom);map2.setZoom(mapZoom);map1.setMapTypeId(map1Type);map2.setMapTypeId(map2Type);return true;}