Commit 084f69c2 authored by friendica's avatar friendica

port openstreetmap - but has issues

parent 96a213de
____ OpenStreetMap Plugin ____
by Mike Macgirvin
Klaus Weidenbach
This addon allows you to use OpenStreetMap for displaying locations.
___ Requirements ___
To use this plugin you need a tile Server that provides the maps.
OpenStreetMap data is free for everyone to use. Their tile servers are not.
Please take a look at their "Tile Usage Policy":
http://wiki.openstreetmap.org/wiki/Tile_usage_policy
You can run your own tile server or choose one from their list of public
tile servers: http://wiki.openstreetmap.org/wiki/TMS
Support the OpenStreetMap community and share the load.
___ Configuration ___
If you for any reason prefer to use a configuration file instead
of the admin panels, please refer to the Alternative Configuration below.
Activate the plugin from your admin panel.
You can now add a Tile Server and default zoom level in the plugin settings
page of your admin panel.
The Time Server URL points to the tile server you want to use. Use the full URL,
with protocol (http/s) and trailing slash. You can configure the default zoom
level on the map in the Default Zoom box. 1 will show the whole world and 18 is the highest
zoom level available.
___ Alternative Configuration ___
Open the .htconfig.php file and add "openstreetmap" to the list of activated
addons.
$a->config['system']['addon'] = "openstreetmap, ..."
You have to add two configuration variables for the addon:
$a->config['openstreetmap']['tmsserver'] = 'http://www.openstreetmap.org/';
$a->config['openstreetmap']['zoom'] = '18';
The *tmsserver* points to the tile server you want to use. Use the full URL,
with protocol (http/s) and trailing slash. You can configure the default zoom
level on the map with *zoom*. 1 will show the whole world and 18 is the highest
zoom level available.
\ No newline at end of file
# ADDON openstreetmap
# Copyright (C)
# This file is distributed under the same license as the Friendica openstreetmap addon package.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-27 05:01-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: openstreetmap.php:94
msgid "Submit"
msgstr ""
#: openstreetmap.php:95
msgid "Tile Server URL"
msgstr ""
#: openstreetmap.php:95
msgid ""
"A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank"
"\">public tile servers</a>"
msgstr ""
#: openstreetmap.php:96
msgid "Default zoom"
msgstr ""
#: openstreetmap.php:96
msgid "The default zoom level. (1:world, 18:highest)"
msgstr ""
#: openstreetmap.php:104
msgid "Settings updated."
msgstr ""
<?php
$a->strings["Submit"] = "Enviar";
$a->strings["Tile Server URL"] = "URL del servidor, del mosaico de servidores";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Una llista de <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\"> un mosaic de servidors públics</a>";
$a->strings["Default zoom"] = "Zoom per defecte";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Nivell de zoom per defecte. (1: el món, 18: el més alt)";
$a->strings["Settings updated."] = "Ajustos actualitzats.";
<?php
$a->strings["Submit"] = "Odeslat";
$a->strings["Tile Server URL"] = "URL adresa Tile serveru";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Seznam <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">veřejných tile serverů</a>";
$a->strings["Default zoom"] = "Defaultní přiblížení";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Defaultní úroveň přiblížení (1:svět, 18:nejvyšší)";
$a->strings["Settings updated."] = "Nastavení aktualizováno.";
<?php
$a->strings["Submit"] = "Senden";
$a->strings["Tile Server URL"] = "Tile Server URL";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Eine Liste <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">öffentlicher Tile Server</a>";
$a->strings["Default zoom"] = "Standard Zoom";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Standard Zoomlevel (1: Welt; 18: höchstes)";
$a->strings["Settings updated."] = "Einstellungen aktualisiert.";
<?php
$a->strings["Submit"] = "Sendi";
$a->strings["Tile Server URL"] = "Adreso de Kahelservilo";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Listo de <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">publikaj kahelserviloj</a>";
$a->strings["Default zoom"] = "Defaŭlta zoma faktoro";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "La defaŭlta zoma faktoro. (1:tutmonda, 18:plej proksima)";
$a->strings["Settings updated."] = "Agordoj ĝisdatigita.";
<?php
$a->strings["Submit"] = "Envíar";
$a->strings["Tile Server URL"] = "Dirección del servidor";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Un listado de <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">servidores públicos</a>";
$a->strings["Default zoom"] = "Zoom por defecto";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Nivel de zoom predeterminado. (1:mínimo, 18:máximo)";
$a->strings["Settings updated."] = "Configuración actualizada.";
<?php
$a->strings["Submit"] = "Envoyer";
$a->strings["Tile Server URL"] = "URL du serveur de tuiles";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Une liste de <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">serveurs de tuiles publics</a>";
$a->strings["Default zoom"] = "Zoom par défaut";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Le niveau de zoom affiché par défaut. (1: monde entier, 18: détail maximum)";
$a->strings["Settings updated."] = "Réglages mis à jour.";
<?php
$a->strings["Submit"] = "Senda inn";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "";
$a->strings["Default zoom"] = "Sjálfgefin þysjun";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "Sjálfgefna þysjunar sig. (1:heimur, 18:mest)";
$a->strings["Settings updated."] = "Stillingar uppfærðar";
<?php
$a->strings["Submit"] = "Invia";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "";
$a->strings["Default zoom"] = "Default zoom";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "";
$a->strings["Settings updated."] = "Impostazioni aggiornate.";
<?php
$a->strings["Submit"] = "Lagre";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "";
$a->strings["Default zoom"] = "";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "";
$a->strings["Settings updated."] = "Innstillinger oppdatert.";
<?php
$a->strings["Submit"] = "Potwierdź";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "";
$a->strings["Default zoom"] = "Domyślne przybliżenie";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "";
$a->strings["Settings updated."] = "Zaktualizowano ustawienia.";
<?php
$a->strings["Submit"] = "Enviar";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "";
$a->strings["Default zoom"] = "Zoom padrão";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "O nível padrão de zoom. (1:mundo, 18:máximo) ";
$a->strings["Settings updated."] = "As configurações foram atualizadas.";
<?php
$a->strings["Submit"] = "Подтвердить";
$a->strings["Tile Server URL"] = "";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "Список <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">общедоступных серверов</a>";
$a->strings["Default zoom"] = "zoom по умолчанию";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "";
$a->strings["Settings updated."] = "Настройки обновлены.";
<?php
$a->strings["Submit"] = "Spara";
$a->strings["Settings updated."] = "Inst&auml;llningarna har uppdaterats.";
<?php
$a->strings["Submit"] = "提交";
$a->strings["Tile Server URL"] = "砖服务器URL";
$a->strings["A list of <a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">public tile servers</a>"] = "一单<a href=\"http://wiki.openstreetmap.org/wiki/TMS\" target=\"_blank\">公共砖服务器</a>";
$a->strings["Default zoom"] = "默认变焦距";
$a->strings["The default zoom level. (1:world, 18:highest)"] = "默认变焦距。(1:世界, 18:最高)";
$a->strings["Settings updated."] = "设置跟新了";
var toolserver = 'http://toolserver.org/~kolossos/openlayers/kml-on-ol.php';
var startTag = '<iframe class="osmFrame" style="width: 100%; height: 350px; clear: both;" src="'+ toolserver + '?lang=de&amp;uselang=de&amp;params=';
var endTag = '"></iframe>';
jQuery(document).ready(function($) {
$('.wall-item-content-wrapper').each(function(index) {
var link = $(this).find('.wall-item-location .OSMMapLink');
link.toggle(addIframe, removeIframe);
});
});
function addIframe(ev) {
var coordinate = $(ev.target).attr('title');
var newTag = startTag + convertCoordinateString(coordinate) + endTag;
$(ev.target).parents('.wall-item-content-wrapper').append(newTag);
}
function removeIframe(ev) {
$(ev.target).parents('.wall-item-content-wrapper').find('iframe').remove();
}
function convertCoordinateString(coordinate) {
var locstring = coordinate.split(' ');
var northSouth;
var westEast;
if (locstring[0] < 0) {
northSouth = '_S_';
}else{
northSouth = '_N_';
}
if (locstring[1] < 0) {
westEast = '_W';
}else{
westEast = '_E';
}
return Math.abs(locstring[0]) + northSouth + Math.abs(locstring[1]) + westEast;
}
\ No newline at end of file
<?php
/**
* Name: OpenStreetMap
* Description: Use OpenStreetMap for displaying locations. After activation the post location just beneath your avatar in your posts will link to openstreetmap.
* Version: 1.1
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
* Author: Klaus Weidenbach
*
*/
function openstreetmap_load() {
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
register_hook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
logger("installed openstreetmap");
}
function openstreetmap_unload() {
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
unregister_hook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
logger("removed openstreetmap");
}
function openstreetmap_alterheader($a, &$navHtml) {
$addScriptTag='<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/openstreetmap/openstreetmap.js' . '"></script>' . "\r\n";
$a->page['htmlhead'] .= $addScriptTag;
}
function openstreetmap_location($a, &$item) {
//
if(! (strlen($item['location']) || strlen($item['coord'])))
return;
/*
* Get the configuration variables from the .htconfig file.
*/
$tmsserver = get_config('openstreetmap','tmsserver');
if(! $tmsserver)
$tmsserver = 'http://openstreetmap.org';
$zoom = get_config('openstreetmap','zoom');
if(! $zoom)
$zoom = 17;
$location = '';
$coord = '';
// if($item['location'] && !$item['coord']) { //if only a location is given, find the lat-lon
// performance hog - we need a better way to do this.
// $geo_account='guest';
// $s = z_fetch_url('http://api.geonames.org/search?maxRows=1&fuzzy=0.8&q=' . urlencode($item['location']) . '&username=' . $geo_account);
// if($s['success']){
// $xml = parse_xml_string($s['body']);
// if($xml->geoname->lat && $xml->geoname->lng){
// $item['coord'] = $xml->geoname->lat . ' ' . $xml->geoname->lng;
// }
// }
// }
$location = (($item['location']) ? $item['location'] : '');
$location = (($location && (! $item['coord'])) ? '<a target="map" title="' . $item['location'] . '" href="'.$tmsserver.'?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : $location);
if($item['coord']) {
$coords = explode(' ', $item['coord']);
if(count($coords) > 1) {
$coord = '<a target="map" class="OSMMapLink" title="' . $item['coord'] . '" href="'.$tmsserver.'?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom='.$zoom.'"> Map </a>' ;
}
}
if(strlen($coord)) {
if($location)
$location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
else
$location = '<span class="smalltext">' . $coord . '</span>';
}
$item['html'] = $location;
return;
}
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('Submit'),
'$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)')),
));
}
function openstreetmap_plugin_admin_post (&$a) {
$url = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
$zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '17');
set_config('openstreetmap', 'tmsserver', $url);
set_config('openstreetmap', 'zoom', $zoom);
info( t('Settings updated.'). EOL);
}
{{include file="field_input.tpl" field=$tmsserver}}
{{include file="field_input.tpl" field=$zoom}}
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment