-function openstreetmap_plugin_admin (&$a, &$o) {
- $t = get_markup_template( "admin.tpl", "addon/openstreetmap/" );
- $tmsserver = get_config('openstreetmap','tmsserver');
- if(! $tmsserver)
- $tmsserver = 'http://openstreetmap.org';
- $zoom = get_config('openstreetmap','zoom');
- if(! $zoom)
- $zoom = 17;
-
- $o = replace_macros( $t, array(
- '$submit' => t('Save Settings'),
- '$tmsserver' => array('tmsserver', t('Tile Server URL'), $tmsserver, t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank">public tile servers</a>')),
- '$zoom' => array('zoom', t('Default zoom'), $zoom, t('The default zoom level. (1:world, 18:highest)')),
- ));
+ $zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
+ $marker = DI::config()->get('openstreetmap', 'marker', OSM_MARKER);
+
+ $lat = $b['lat']; // round($b['lat'], 5);
+ $lon = $b['lon']; // round($b['lon'], 5);
+
+ Logger::log('lat: ' . $lat, Logger::DATA);
+ Logger::log('lon: ' . $lon, Logger::DATA);
+
+ $cardlink = '<a href="' . $tmsserver;
+
+ if ($marker > 0) {
+ $cardlink .= '?mlat=' . $lat . '&mlon=' . $lon;
+ }
+
+ $cardlink .= '#map=' . $zoom . '/' . $lat . '/' . $lon . '">' . ($b['location'] ? Strings::escapeHtml($b['location']) : DI::l10n()->t('View Larger')) . '</a>';
+ if (empty($b['mode'])) {
+ $b['html'] = '<iframe style="width:100%; height:300px; border:1px solid #ccc" src="' . $tmsserver .
+ '/export/embed.html?bbox=' . ($lon - 0.01) . '%2C' . ($lat - 0.01) . '%2C' . ($lon + 0.01) . '%2C' . ($lat + 0.01) .
+ '&layer=mapnik&marker=' . $lat . '%2C' . $lon . '" style="border: 1px solid black"></iframe>' .
+ '<br/><small>' . $cardlink . '</small>';
+ } else {
+ $b['html'] .= '<br/>' . $cardlink;
+ }
+
+ Logger::log('generate_map: ' . $b['html'], Logger::DATA);
+}
+
+function openstreetmap_addon_admin(&$a, &$o)
+{
+ $t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/");
+ $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
+ $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
+ $zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
+ $marker = DI::config()->get('openstreetmap', 'marker', OSM_MARKER);
+
+ // This is needed since we stored an empty string in the config in previous versions
+ if (empty($nomserver)) {
+ $nomserver = OSM_NOM;
+ }
+
+ $o = Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Submit'),
+ '$tmsserver' => ['tmsserver', DI::l10n()->t('Tile Server URL'), $tmsserver, DI::l10n()->t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank">public tile servers</a>')],
+ '$nomserver' => ['nomserver', DI::l10n()->t('Nominatim (reverse geocoding) Server URL'), $nomserver, DI::l10n()->t('A list of <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim servers</a>')],
+ '$zoom' => ['zoom', DI::l10n()->t('Default zoom'), $zoom, DI::l10n()->t('The default zoom level. (1:world, 18:highest, also depends on tile server)')],
+ '$marker' => ['marker', DI::l10n()->t('Include marker on map'), $marker, DI::l10n()->t('Include a marker on the map.')],
+ ]);