User:Zocky/Map.js

document.write('<'+'script type="text/javascript" src="'               + 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAcI9V6O8AJatRG-P1Ao7swBQQcp3yHfYdvNF2yMwM3uUI13B9EhSmf_wGb8aYtyczGT_QitbWCJoQFw'                + '&action=raw&ctype=text/javascript&dontcountme=s">');

document.addEventListener('click',mapOnClick,true);

function mapOnClick(e) { var t=e.target; if (t.tagName=='A' && t.href.match(/geohack\.php\?params=/)) { //   alert(t.href); var lat=t.href.replace(/^.*?([\d\.]+)_(([\d\.]+)_)?(([\d\.]+)_)?([SN]).*$/,mapConvert); var long=t.href.replace(/^.*?([\d\.]+)_(([\d\.]+)_)?(([\d\.]+)_)?([EW]).*$/,mapConvert); //   alert(lat+','+long); document.getElementById('content').innerHTML=' ' + document.getElementById('content').innerHTML;

if (GBrowserIsCompatible) {     var map = new GMap2(document.getElementById("mapMap")); map.addControl(new GLargeMapControl); map.addControl(new GMapTypeControl); var point=new GLatLng(lat,long); var marker = new GMarker(point); map.setCenter(new GLatLng(lat, long), 10); map.addOverlay(marker); e.preventDefault; } } }

function mapConvert(p,p1,d2,p2,d3,p3,p4) { // alert(p1+","+p2+","+p3+","+p4); c=Math.round((parseFloat(0+p1)+parseFloat(0+p2)/60+parseFloat(0+p3)/3600)*1000000)/1000000; if (p4=='W' || p4=='S') return -c; return c; }