'500',
'height' => '300',
'id' => 'map',
'view' => 'normal',
'zoom' => '13',
'coordinates' => array('lon' => '42.72500', 'lat' => '-81.200935'),
'address' => '',
'user-address' => false
) );
# HTMLHeader Defaults
$HTMLHeaderFmt[] = '';
# Other Defaults
$Parser = new Parse( &$GoogleMapDefaults );
$ParsedParams = null; // used by the parser
$HTMLHandle = new HtmlInterface();
$HTMLHandle->AddHtml( 'var map = null;
var geocoder = null;
function load() {
var map = new GMap2(document.getElementById("' . $GoogleMapDefaults['id'] . '"));
var geocoder = new GClientGeocoder();
if (GBrowserIsCompatible()) {
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());' );
# Markup() Call
Markup( 'map', '_begin', '/\(:map(-location\s|-end\s|\s)(.*?):\)/ie',
"CvtMarkup(PSS('$1'), PSS('$2'))" );
/********************************
* Function Definitions.
* AKA: The Fun Stuff
*******************************/
/* (string) furncion cvtMarkup($call, $params);
* Discription: Main() function of script. CvtMarkup() checkes for the markup call
* used, and makes a call to one of two fucntions depending on call
* type. CvtMarkup() returns the result of this function call to the
* wiki, which is the html needed to preform the action requested.
*/
function CvtMarkup( $call, $params )
{
global $Parser;
# Deturmine the call type.
if ( strpos( $call, '-location' ) === 0 )
{
$type = 'location';
}
elseif ( strpos( $call, '-end' ) === 0 )
{
$type = 'end';
}
else
{
$type = 'generate';
}
# Get the paramaters passed to the scirpt; pass through PmWiki's ParseArgs to
# make things easy
$args = ParseArgs( $params );
#Add paramaters to the Parser
$Parser->AddCallParams ( $args );
# Pass controll to another part of the script, depending on the call type.
if ( $type == 'generate' )
{
$replace = GenerateMap();
}
elseif ( $type == 'location' )
{
$replace = AddLocation();
}
elseif ( $type == 'end' )
{
GoogleMapsDestruct();
}
return $replace;
}
/* (string) GenerateMap();
* Discription: GenerateMap() does just as it's name implies: it generates a map.
* More specifically though, it adds the javascript from the Google
* Maps API, which generates the map for it.
*/
function GenerateMap( )
{
global $GoogleMapDefaults, $ParsedParams, $Parser, $HTMLHandle;
/*
* Time to parse the arguments
*/
// address/coordinates
$loctype = $Parser->ParseAddr();
$Parser->ParseZoom();
// generate javascript for setting center.
if ( $loctype == 'll' )
{
$HTMLHandle->addHtml( " \n" . 'map.setCenter(new GLatLng(' . $ParsedParams['coordinates']['lon'] . ',' . $ParsedParams['coordinates']['lat'] . '),' . $GoogleMapDefaults['zoom'] . ');' );
}
elseif ( $loctype == 'addr' )
{
$HTMLHandle->addHtml( "\n" . 'geocoder.getLatLng(
\''. $ParsedParams['address'] . '\',
function(point) {
if (!point) {
alert(" not found");
} else {
map.setCenter(point, ' . $ParsedParams['zoom'] . ');
}
});' );
}
/*
* Check for user-address'
*/
$Parser->ParseUserAddrBool();
$form = null;
if ( $ParsedParams['user-address'] )
{
# Figure out method of getting group and page name later to use here
$form = '