tag
/// @param $args array - the array of attribute name/value pairs for the tag
/// @param $parser Parser - the MW Parser object for the current page
///
/// @return string - the html for rendering the map
public static function render($content, $args, $parser, $frame) {
// Unfortunately, $tagname is no argument of this function, therefore we have to use a trick with derived classes.
$tagname = strtolower(get_called_class()); // either wrmap or wrgmap
assert(in_array($tagname, array('wrmap', 'wrgmap')));
$parserOutput = $parser->getOutput();
$parserOutput->addHeadItem('', 'googlemaps');
$parserOutput->addModules('ext.wrmap');
// append all sledruns as icon
$json_features = array();
$show_sledruns = ($tagname == 'wrgmap');
if ($show_sledruns) {
$json_features = array_merge($json_features, sledruns_to_json_features());
}
try {
// map properties
$properties = array();
if (isset($args['lat'])) $properties['lat'] = (float) $args['lat']; // latitude as float value
if (isset($args['lon'])) $properties['lon'] = (float) $args['lon']; // longitude as float value
if (isset($args['zoom'])) $properties['zoom'] = (int) $args['zoom']; // zoom as int value
if (isset($args['width'])) $properties['width'] = (int) $args['width']; // width as int value
if (isset($args['height'])) $properties['height'] = (int) $args['height']; // height as int value
// append all elements in the XML
$json_features = array_merge($json_features, xml_to_json_features('' . $content . ''));
} catch (Exception $e) {
return '' . htmlspecialchars("Fehler beim Parsen der Landkarte: " . $e->getMessage()) . '
';
}
// create final geojson
$json = array(
'type' => 'FeatureCollection',
'features' => $json_features,
'properties' => $properties
);
$json_string = json_encode($json);
// Create element where the map is placed in
global $wgExtensionAssetsPath;
$output = "";
$output .= htmlspecialchars($json_string, ENT_NOQUOTES);
$output .= "
\n";
return array($output, 'markerType' => 'nowiki');
}
}
// tag
class WrMap extends WrBaseMap {
}
// tag
class WrGMap extends WrBaseMap {
}
?>