|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* webtrees: online genealogy |
|
5
|
|
|
* Copyright (C) 2021 webtrees development team |
|
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU General Public License for more details. |
|
14
|
|
|
* You should have received a copy of the GNU General Public License |
|
15
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
declare(strict_types=1); |
|
19
|
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees\Module; |
|
21
|
|
|
|
|
22
|
|
|
use Fisharebest\Webtrees\Fact; |
|
23
|
|
|
use Fisharebest\Webtrees\I18N; |
|
24
|
|
|
|
|
25
|
|
|
use function strip_tags; |
|
26
|
|
|
use function view; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class MapLinkBingModule - show locations in external maps |
|
30
|
|
|
*/ |
|
31
|
|
|
class MapLinkBingModule extends AbstractModule implements ModuleMapLinkInterface |
|
32
|
|
|
{ |
|
33
|
|
|
use ModuleMapLinkTrait; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Name of the map provider. |
|
37
|
|
|
* |
|
38
|
|
|
* @return string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected function providerName(): string |
|
41
|
|
|
{ |
|
42
|
|
|
return I18N::translate('Bing™ maps'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return string |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function icon(): string |
|
49
|
|
|
{ |
|
50
|
|
|
return view('icons/bing-maps'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param Fact $fact |
|
55
|
|
|
* |
|
56
|
|
|
* @return string |
|
57
|
|
|
*/ |
|
58
|
|
|
protected function mapUrl(Fact $fact): string |
|
59
|
|
|
{ |
|
60
|
|
|
$latitude = $fact->latitude(); |
|
61
|
|
|
$longitude = $fact->longitude(); |
|
62
|
|
|
$center = $latitude . '~' . $longitude; |
|
63
|
|
|
$label = strip_tags($fact->record()->fullName()) . ' — ' . $fact->label(); |
|
64
|
|
|
$pointer = $latitude . '_' . $longitude . '_' . rawurlencode($label); |
|
65
|
|
|
|
|
66
|
|
|
return 'http://www.bing.com/maps/?v=2&cp=' . $center . '&lvl=10&dir=0&sty=o&sp=point.' . $pointer; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|