/** * Returns the JSON with the maps data. * * @since 1.0 * * @param array $params * @param Parser $parser * @param string $mapName * * @return string */ protected function getJSON(array $params, Parser $parser, $mapName) { $object = $this->getJSONObject($params, $parser); if ($object === false) { return ''; } return Html::inlineScript(MapsMapper::getBaseMapJSON($this->service->getName()) . "mwmaps.{$this->service->getName()}.{$mapName}=" . FormatJson::encode($object) . ';'); }
/** * Translates the coordinates field to the centre field and makes sure it's set to it's default when invalid. * * @since 1.0 * * @param array &$params */ protected function setCentre(array &$params) { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used. if ($params['coordinates'] === false) { global $egMapsDefaultMapCentre; $centre = MapsGeocoders::attemptToGeocode($egMapsDefaultMapCentre, $params['geoservice'], $this->service->getName()); if ($centre === false) { throw new Exception('Failed to parse the default centre for the map. Please check the value of $egMapsDefaultMapCentre.'); } else { $params['centre'] = $centre; } } else { $params['centre'] = $params['coordinates']; } unset($params['coordinates']); }
/** * Returns the HTML to display the map. * * @since 2.0 * * @param array $params * @param Parser $parser * @param string $mapName * * @return string */ protected function getMapHTML(array $params, Parser $parser, $mapName) { return Html::rawElement('div', array('id' => $mapName, 'style' => "width: {$params['width']}; height: {$params['height']}; background-color: #cccccc; overflow: hidden;", 'class' => 'maps-map maps-' . $this->service->getName()), wfMessage('maps-loading-map')->inContentLanguage()->escaped() . Html::element('div', array('style' => 'display:none', 'class' => 'mapdata'), FormatJson::encode($this->getJSONObject($params, $parser)))); }
/** * Returns the internationalized name of the mapping service. * * @return string */ public final function getName() { return wfMessage('maps_' . $this->service->getName())->text(); }
/** * Returns the internationalized name of the mapping service. * * @return string */ public final function getName() { return wfMsg( 'maps_' . $this->service->getName() ); }
/** * Returns the HTML to display the map input. * * @since 1.0 * * @param array $params * @param Parser $parser * @param string $mapName * * @return string */ protected function getInputHTML(array $params, Parser $parser, $mapName) { return Html::rawElement('div', array('id' => $mapName . '_forminput', 'style' => 'display: inline', 'class' => 'sminput sminput-' . $this->service->getName()), wfMessage('semanticmaps-loading-forminput')->escaped() . Html::element('div', array('style' => 'display:none', 'class' => 'sminputdata'), FormatJson::encode($this->getJSONObject($params, $parser)))); }