]> git.mxchange.org Git - friendica-addons.git/blob - googlemaps/googlemaps.php
New plugin GoogleMaps, changed map format for OSM
[friendica-addons.git] / googlemaps / googlemaps.php
1 <?php
2 /**
3  * Name: Google Maps
4  * Description: Use Google Maps for displaying locations. After activation the post location just beneath your avatar in your posts will link to Google Maps.
5  * Version: 0.1
6  * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
7  *
8  */
9
10 require_once('include/cache.php');
11
12
13 function googlemaps_install() {
14         register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
15
16         logger("installed googlemaps");
17 }
18
19 function googlemaps_uninstall() {
20         unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
21
22         logger("removed googlemaps");
23 }
24
25 function googlemaps_location($a, &$item) {
26
27         if(! (strlen($item['location']) || strlen($item['coord'])))
28                 return;
29
30         if ($item['coord'] != "")
31                 $target = "http://maps.google.com/?q=".urlencode($item['coord']);
32         else
33                 $target = "http://maps.google.com/?q=".urlencode($item['location']);
34
35         if ($item['location'] != "")
36                 $title = $item['location'];
37         else
38                 $title = $item['coord'];
39
40         $item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
41 }