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