latitude and 1=>longitude. * Gmap_... returns a javascript call that creates a Google Map GLatLng object */ if (!function_exists(OSGBgridref)) { function OSGBgridref($OSGBgridref) { /* Trim whitespace */ $OSGBgridref = str_replace(' ', '',$OSGBgridref); /* Pre-pend SE if required */ if (ctype_digit($OSGBgridref)) $OSGBgridref='SE'.$OSGBgridref; /* Convert 8 and 10 figure grid refs to 6-figure) */ if(strlen($OSGBgridref)==10) $OSGBgridref = substr($OSGBgridref, 0, 5).substr($OSGBgridref, 6, 3); elseif (strlen($OSGBgridref)==12) $OSGBgridref = substr($OSGBgridref, 0, 5).substr($OSGBgridref, 7, 3); if (ereg('^[[:alpha:]]{2}[[:digit:]]{6}$',$OSGBgridref)) { $OSGBresult = explode (' ', shell_exec('cd '.MODX_BASE_PATH.'assets/snippets/osgb/ && perl osgb.pl '.$OSGBgridref)); $OSGBresult[0] = trim($OSGBresult[0]); $OSGBresult[1] = trim($OSGBresult[1]); if (sizeof($OSGBresult) == 2 && is_numeric($OSGBresult[0]) && is_numeric($OSGBresult[1])) return $OSGBresult; else return array(0, 0); } else return array(0,0); } } if (!function_exists(Gmap_OSGBgridref)) { function Gmap_OSGBgridref($OSGBgridref) { $OSGBlatlong = OSGBgridref($OSGBgridref); return "new GLatLng({$OSGBlatlong[0]}, {$OSGBlatlong[1]})"; } } return Gmap_OSGBgridref($OSGBgridref); ?>