2015-05-15 20:41:10 +02:00
|
|
|
<?php
|
2017-12-13 22:38:14 +01:00
|
|
|
/**
|
|
|
|
* @file src/Util/Map.php
|
|
|
|
*/
|
|
|
|
namespace Friendica\Util;
|
2015-05-15 20:41:10 +02:00
|
|
|
|
2018-01-17 19:42:40 +01:00
|
|
|
use Friendica\Core\Addon;
|
|
|
|
|
2015-05-15 20:41:10 +02:00
|
|
|
/**
|
|
|
|
* Leaflet Map related functions
|
|
|
|
*/
|
2017-12-13 22:38:14 +01:00
|
|
|
class Map {
|
2018-03-20 07:32:17 +01:00
|
|
|
public static function byCoordinates($coord, $html_mode = 0) {
|
2017-12-13 22:38:14 +01:00
|
|
|
$coord = trim($coord);
|
2018-01-15 14:05:12 +01:00
|
|
|
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
|
2018-03-20 07:32:17 +01:00
|
|
|
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => ''];
|
2018-01-17 19:42:40 +01:00
|
|
|
Addon::callHooks('generate_map',$arr);
|
2017-12-13 22:38:14 +01:00
|
|
|
return ($arr['html']) ? $arr['html'] : $coord;
|
|
|
|
}
|
|
|
|
|
2018-03-20 07:32:17 +01:00
|
|
|
public static function byLocation($location, $html_mode = 0) {
|
|
|
|
$arr = ['location' => $location, 'mode' => $html_mode, 'html' => ''];
|
2018-01-17 19:42:40 +01:00
|
|
|
Addon::callHooks('generate_named_map',$arr);
|
2017-12-13 22:38:14 +01:00
|
|
|
return ($arr['html']) ? $arr['html'] : $location;
|
|
|
|
}
|
2018-03-20 07:32:17 +01:00
|
|
|
|
|
|
|
public static function getCoordinates($location) {
|
|
|
|
$arr = ['location' => $location, 'lat' => false, 'lon' => false];
|
|
|
|
Addon::callHooks('Map::getCoordinates', $arr);
|
|
|
|
return $arr;
|
|
|
|
}
|
2015-05-15 20:41:10 +02:00
|
|
|
}
|