2015-05-15 14:41:10 -04:00
|
|
|
<?php
|
2017-12-13 16:38:14 -05:00
|
|
|
/**
|
2021-03-29 02:40:20 -04:00
|
|
|
* @copyright Copyright (C) 2010-2021, the Friendica project
|
2020-02-09 10:18:46 -05:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
2017-12-13 16:38:14 -05:00
|
|
|
*/
|
2020-02-09 10:18:46 -05:00
|
|
|
|
2017-12-13 16:38:14 -05:00
|
|
|
namespace Friendica\Util;
|
2015-05-15 14:41:10 -04:00
|
|
|
|
2018-12-26 01:06:24 -05:00
|
|
|
use Friendica\Core\Hook;
|
2018-01-17 13:42:40 -05:00
|
|
|
|
2015-05-15 14:41:10 -04:00
|
|
|
/**
|
|
|
|
* Leaflet Map related functions
|
|
|
|
*/
|
2017-12-13 16:38:14 -05:00
|
|
|
class Map {
|
2018-03-20 02:32:17 -04:00
|
|
|
public static function byCoordinates($coord, $html_mode = 0) {
|
2017-12-13 16:38:14 -05:00
|
|
|
$coord = trim($coord);
|
2018-01-15 08:05:12 -05:00
|
|
|
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
|
2018-03-20 02:32:17 -04:00
|
|
|
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => ''];
|
2018-12-26 01:06:24 -05:00
|
|
|
Hook::callAll('generate_map',$arr);
|
2017-12-13 16:38:14 -05:00
|
|
|
return ($arr['html']) ? $arr['html'] : $coord;
|
|
|
|
}
|
|
|
|
|
2018-03-20 02:32:17 -04:00
|
|
|
public static function byLocation($location, $html_mode = 0) {
|
|
|
|
$arr = ['location' => $location, 'mode' => $html_mode, 'html' => ''];
|
2018-12-26 01:06:24 -05:00
|
|
|
Hook::callAll('generate_named_map',$arr);
|
2017-12-13 16:38:14 -05:00
|
|
|
return ($arr['html']) ? $arr['html'] : $location;
|
|
|
|
}
|
2018-03-20 02:32:17 -04:00
|
|
|
|
|
|
|
public static function getCoordinates($location) {
|
|
|
|
$arr = ['location' => $location, 'lat' => false, 'lon' => false];
|
2018-12-26 01:06:24 -05:00
|
|
|
Hook::callAll('Map::getCoordinates', $arr);
|
2018-03-20 02:32:17 -04:00
|
|
|
return $arr;
|
|
|
|
}
|
2015-05-15 14:41:10 -04:00
|
|
|
}
|