3 * Name: Open Street Map
4 * Description: Use openstreetmap.org for displaying locations.
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function openstreetmap_install() {
14 register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
16 logger("installed openstreetmap");
20 function openstreetmap_uninstall() {
22 unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
24 logger("removed openstreetmap");
29 function openstreetmap_location($a, &$item) {
31 if(! (strlen($item['location']) || strlen($item['coord'])))
37 $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://www.openstreetmap.org/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
40 $coords = explode(' ', $item['coord']);
41 if(count($coords) > 1) {
42 $coord = '<a target="map" title="' . $item['coord'] . '" href="http://www.openstreetmap.org/?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom=18">' . $item['coord'] . '</a>' ;
47 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
49 $location = '<span class="smalltext">' . $coord . '</span>';
51 $item['html'] = $location;