Download the following files:

  • MODx snippet to implement a variation of the aforementioned caller.php PHP script. Name it OSGB_SE. It doesn't contain quite the same functions as caller.php, and the main function, OSGBgridref(), returns array(0,0) on failure. Whilst not a good solution, particularly if you expect to occasionally receive incorrect grid references to process, it means that the javascript provided below will not throw an error if the grid reference is invalid. In many cases this will not be a reasonable solution.
  • Javascript to create a map centred at the location stored in template variable . Position the script in the <head>. This code expects to find an element on the page with id="gmap". I suggest using CSS to give this element a fixed size.

    It also includes a ditto call to create markers on this map according to the value of the same template variable in all child documents. If you don't require such markers, just delete the call.

  • Ditto template for the above ditto call.
    • This includes a commented modx document id, making debugging easier.
    • The bindInfoWindow call results in a window or ‘bubble’ being associated with each marker; these appear when the user hovers over the relevant marker on the map. In this version the window contains the [+pagetitle+] which is a link to the relevant page/document.

Don't forget to replace YOURKEYHERE in the Javascript with your own (freely obtainable) Google maps key.

Note to IE users: IE may try and parse the javascript file instead of displaying it - If so, right click and 'Save Target As...'