]> git.mxchange.org Git - friendica-addons.git/blob - openstreetmap/openstreetmap.php
add openstreetmap
[friendica-addons.git] / openstreetmap / openstreetmap.php
1 <?php
2 /**
3  * Name: Open Street Map
4  * Description: Use openstreetmap.org for displaying locations.
5  * Version: 1.0
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * 
8  *
9  */
10
11
12 function openstreetmap_install() {
13
14         register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
15
16         logger("installed openstreetmap");
17 }
18
19
20 function openstreetmap_uninstall() {
21
22         unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
23
24         logger("removed openstreetmap");
25 }
26
27
28
29 function openstreetmap_location($a, &$item) {
30
31         $location = '';
32         $coord = '';
33
34         $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://www.openstreetmap.org/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
35
36         if($item['coord']) {
37                 $coords = explode(' ', $item['coord']);
38                 if(count($coords) > 1) {
39                         $coord = '<a target="map" title="' . $item['coord'] . '" href="http://www.openstreetmap.org/?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom=10">' . $item['coord'] . '</a>' ;
40                 }
41         }
42         if(strlen($coord)) {
43                 if($location)
44                         $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
45                 else
46                         $location = '<span class="smalltext">' . $coord . '</span>';
47         }
48         $item['html'] = $location;
49         return;
50 }
51