Difference between revisions of "GeocachingAustPrint"

From GeoWiki
Jump to: navigation, search
(The Script)
(Printing Geocaching.com Cache Pages: Link to Greasemonkey script page)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== printing Geocaching Caches ==
+
== Printing Geocaching.com Cache Pages==
Currrent the GeoCaching.com website uses MapQuest data which is fine the the US where these maps have good coverage but for us Ozzies, particularly outside the main Citys there the maps are pretty useless
+
Currently the Geocaching.com website uses MapQuest data which is fine for the US where these maps have good coverage but for us Ozzies, particularly outside the main cities the maps are pretty useless.
 
+
This [[Greasemonkey script]] replaces the MapQuest map with a much more detailed one.
 
 
== GreaseMonkey ==
 
This is an addon to Firefox [[http://greasemonkey.mozdev.org/ GreaseMonkey website]]
 
  
 +
== Requirements ==
 +
* The [http://www.mozilla.com/en-US/firefox/ Firefox] Browser.<br>
 +
* The [http://greasemonkey.mozdev.org/ GreaseMonkey] add-on installed.<br>
 +
* The [http://aylee.net/zactyl/GeocachingAustPrint.user.js GeocachingAustPrint] script installed.
  
 
==The Script==
 
==The Script==
This code will replace the MapQuest graphic when view Cache data on the Geocaching site "when formated for Print" . ie you have selected the link which formats the page for print friendly output.
+
This code will replace the MapQuest graphic when viewing Cache Pages on the Geocaching.com site ''when formatted for Print'' ie you have clicked the "Make this page print-friendly" link on the Cache Page.
Install the script as filename : GeocachingAustPrint (then open with Firefox)
+
Install the script as filename : GeocachingAustPrint.user.js (then open with Firefox) or click [http://aylee.net/zactyl/GeocachingAustPrint.user.js here].
  
 
<pre>
 
<pre>

Latest revision as of 15:41, 16 June 2007

Printing Geocaching.com Cache Pages

Currently the Geocaching.com website uses MapQuest data which is fine for the US where these maps have good coverage but for us Ozzies, particularly outside the main cities the maps are pretty useless. This Greasemonkey script replaces the MapQuest map with a much more detailed one.

Requirements

The Script

This code will replace the MapQuest graphic when viewing Cache Pages on the Geocaching.com site when formatted for Print ie you have clicked the "Make this page print-friendly" link on the Cache Page. Install the script as filename : GeocachingAustPrint.user.js (then open with Firefox) or click here.

/*
Geocaching OS Maps - 0.2 14/01/2007
Copyright (c) 2007, Paul Wilson
Released under the GPL http://www.gnu.org/copyleft/gpl.html

This is a Greasemonkey user script, see http://greasemonkey.mozdev.org/.

This substitutes the lame MapQuest map on cache printout mainly for an
OS map (where MapQuest coverage is not that good)


Modified by Paul Wilson 11th Jan 2007 to work for Australian Maps for printing
*/

// ==UserScript==
// @name          GeocachingAustPrint
// @namespace     http://www.geocaching.com.au/
// @description	  Replaces the MapQuest graphic with Google Maps image
// @include       http://www.geocaching.com/seek/cache_details.aspx?pf=y*
// ==/UserScript==

var win=window;
if (unsafeWindow)
{
	win=unsafeWindow;
}


	var LatLon=document.getElementById("LatLon");
	if (LatLon) {
    var coords=LatLon.innerHTML;
	  //GM_log(coords);
	 
	 	var pattern=/([NS])\s*(\d+)[\xb0\s]+(\d+\.\d+)\s+([WE])\s*(\d+)[\xb0\s]+(\d+\.\d+)/i;
	 	//    pattern=/([NS])\s*(\d+)/i;
		var matches=coords.match(pattern);
	  if (matches) {

	     //for (counter = 0; counter < matches.length; counter++) { GM_log("matches="+counter+'.'+matches[counter]);        }
	     
	     latnorth=matches[1]
	     lat1=matches[2]
	     lat2=matches[3]
	     lonwest=matches[4]
	     long1=matches[5]
	     long2=matches[6]
                    	   
      //GM_log( 'Lat:'+latnorth+lat1+' :'+lat2+': - Long:'+lonwest+long1+' '+long2)
      latdir=''
      longdir=''
      if (latnorth == 'S') latdir='-'
      if (lonwest == 'W') longdir='-'
      latdec=Math.round(lat1)+lat2/60
      londec=Math.round(long1)+long2/60
      gmdatalat=latdir+latdec.toFixed(6)
      gmdatalon=longdir+londec.toFixed(6)
      //GM_log( 'Latdec:'+gmdatalat+' LongDec:'+gmdatalon)
      gmx=gmdatalat*Math.pow(10,6)
      gmy=gmdatalon*Math.pow(10,6)
      if (gmx < 0) gmx=gmx+Math.pow(2,32)
      GM_log( 'Latx:'+gmx+' ('+gmdatalat+') Longy:'+gmy+'  ('+gmdatalon+')')
      
	   var LargeMap = document.getElementById("LargeMap");
	   var LargeMapPrint = document.getElementById("LargeMapPrint");

		var mapHTML= '<img src="http://maps.google.com/mapdata?Point=b&Point.latitude_e6=' +gmx +'&Point.longitude_e6='+gmy+'&Point.iconid=15&Point=e&latitude_e6=' +gmx +'&longitude_e6='+gmy+'&zm=2000&w=300&h=280&cc=us&min_priority=1"  BORDER=1 align="right" >';
//		GM_log(mapHTML);
		if (LargeMap)		{
			LargeMap.innerHTML = mapHTML;
			LargeMap.className = "";			
		  }
		else if (LargeMapPrint)		{
			LargeMapPrint.innerHTML = mapHTML;
		  }

      }
    else {
        GM_log('no match on co-ords')
        }
	
	 }