Extension:Semantic Google Maps/InsertMap.php

This parser function includes a Google Map in a page. Can be used in templates. Accepts template-variables as input. setFunctionHook( 'insert_map', 'wfInsert_MapFunction_Render' ); } function wfInsert_MapFunction_Magic( &$magicWords, $langCode ) { # Add the magic word # The first array element is case sensitive, in this case it is not case sensitive # All remaining elements are synonyms for our parser function $magicWords['insert_map'] = array( 0, 'insert_map' ); # unless we return true, other parser functions extensions won't get loaded. return true; } function wfInsert_MapFunction_Render( &$parser, $lat = '1', $lon = '1', $zoom = '2', $type = 'G_HYBRID_MAP', $controls = 'GSmallMapControl', $class = 'pmap', $width = , $height = , $style = '' ) { # The parser function itself # The input parameters are wikitext with templates expanded # The output is not parsed as wikitext global $wgJsMimeType, $wgGoogleMapsKey; $wgGoogleMapsOnThisPage = 99; $output .= ' '; $output .= " function createMarker(point, label) { var marker = new GMarker(point);  GEvent.addListener(marker, 'click', function { marker.openInfoWindowHtml(label); });  return marker;  }  function addLoadEvent(func) {  var oldonload = window.onload;  if (typeof oldonload == 'function') {  window.onload = function {  oldonload;  func;  };  } else {  window.onload = func;  }  }  window.unload = GUnload; "; $output .= ' '; $output .= " function makeMap{$wgGoogleMapsOnThisPage} { if (GBrowserIsCompatible) {var map = new GMap2(document.getElementById(\"map{$wgGoogleMapsOnThisPage}\")); map.addControl(new {$controls}); map.addControl(new GMapTypeControl); map.setCenter(new GLatLng({$lat}, {$lon}), {$zoom}, {$type}); var point = new GLatLng({$lat}, {$lon}); var marker = new GMarker(point); map.addOverlay(marker); } else { document.write('should show map'); } } addLoadEvent(makeMap{$wgGoogleMapsOnThisPage}); "; //$output .= "var map = new GMap2(document.getElementById(\"map{$wgGoogleMapsOnThisPage}\")); map.addControl(new {$controls}); map.addControl(new GMapTypeControl); map.setCenter(new GLatLng({$lat}, {$lon}), {$zoom}, {$type}); "; return array( $output, noparse => true, isHTML => true );
 * 1) Define a setup function
 * 1) Add a hook to initialise the magic word

} ?>