friendica-github/src/Util/Map.php

33 lines
960 B
PHP
Raw Normal View History

2015-05-15 18:41:10 +00:00
<?php
2017-12-13 21:38:14 +00:00
/**
* @file src/Util/Map.php
*/
namespace Friendica\Util;
2015-05-15 18:41:10 +00:00
use Friendica\Core\Hook;
2015-05-15 18:41:10 +00:00
/**
* Leaflet Map related functions
*/
2017-12-13 21:38:14 +00:00
class Map {
public static function byCoordinates($coord, $html_mode = 0) {
2017-12-13 21:38:14 +00:00
$coord = trim($coord);
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => ''];
Hook::callAll('generate_map',$arr);
2017-12-13 21:38:14 +00:00
return ($arr['html']) ? $arr['html'] : $coord;
}
public static function byLocation($location, $html_mode = 0) {
$arr = ['location' => $location, 'mode' => $html_mode, 'html' => ''];
Hook::callAll('generate_named_map',$arr);
2017-12-13 21:38:14 +00:00
return ($arr['html']) ? $arr['html'] : $location;
}
public static function getCoordinates($location) {
$arr = ['location' => $location, 'lat' => false, 'lon' => false];
Hook::callAll('Map::getCoordinates', $arr);
return $arr;
}
2015-05-15 18:41:10 +00:00
}