1c9c6f2ecSGreg Roach<?php 2c9c6f2ecSGreg Roach 3c9c6f2ecSGreg Roach/** 4c9c6f2ecSGreg Roach * webtrees: online genealogy 5c9c6f2ecSGreg Roach * Copyright (C) 2021 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\I18N; 23c9c6f2ecSGreg Roachuse Psr\Http\Message\ResponseInterface; 24c9c6f2ecSGreg Roach 25c9c6f2ecSGreg Roach/** 26c9c6f2ecSGreg Roach * Class OpenStreetMap - use maps within webtrees 27c9c6f2ecSGreg Roach */ 28*2799a6e6SGreg Roachclass OpenStreetMap extends AbstractModule implements ModuleMapProviderInterface 29c9c6f2ecSGreg Roach{ 30c9c6f2ecSGreg Roach use ModuleMapProviderTrait; 31c9c6f2ecSGreg Roach 32c9c6f2ecSGreg Roach /** 33c9c6f2ecSGreg Roach * Name of the map provider. 34c9c6f2ecSGreg Roach * 35c9c6f2ecSGreg Roach * @return string 36c9c6f2ecSGreg Roach */ 37c9c6f2ecSGreg Roach public function description(): string 38c9c6f2ecSGreg Roach { 39c9c6f2ecSGreg Roach $link = '<a href="https://www.openstreetmap.org" dir="ltr">www.openstreetmap.org</a>'; 40c9c6f2ecSGreg Roach 41c9c6f2ecSGreg Roach // I18N: %s is a link/URL 42c9c6f2ecSGreg Roach return I18N::translate('Create maps using %s.', $link); 43c9c6f2ecSGreg Roach } 44c9c6f2ecSGreg Roach 45c9c6f2ecSGreg Roach /** 46c9c6f2ecSGreg Roach * Name of the map provider. 47c9c6f2ecSGreg Roach * 48c9c6f2ecSGreg Roach * @return string 49c9c6f2ecSGreg Roach */ 50c9c6f2ecSGreg Roach public function title(): string 51c9c6f2ecSGreg Roach { 52c9c6f2ecSGreg Roach return I18N::translate('OpenStreetMap™'); 53c9c6f2ecSGreg Roach } 54c9c6f2ecSGreg Roach 55c9c6f2ecSGreg Roach /** 56c9c6f2ecSGreg Roach * @return ResponseInterface 57c9c6f2ecSGreg Roach */ 58c9c6f2ecSGreg Roach public function getAdminAction(): ResponseInterface 59c9c6f2ecSGreg Roach { 60c9c6f2ecSGreg Roach $this->layout = 'layouts/administration'; 61c9c6f2ecSGreg Roach 62c9c6f2ecSGreg Roach return $this->viewResponse('modules/openstreetmap/config', [ 63c9c6f2ecSGreg Roach 'title' => $this->title(), 64c9c6f2ecSGreg Roach ]); 65c9c6f2ecSGreg Roach } 66c9c6f2ecSGreg Roach 67c9c6f2ecSGreg Roach /** 68c9c6f2ecSGreg Roach * Parameters to create a TileLayer in LeafletJs. 69c9c6f2ecSGreg Roach * 70c9c6f2ecSGreg Roach * @return array<object> 71c9c6f2ecSGreg Roach */ 72c9c6f2ecSGreg Roach public function leafletJsTileLayers(): array 73c9c6f2ecSGreg Roach { 74c9c6f2ecSGreg Roach return [ 75c9c6f2ecSGreg Roach (object) [ 76c9c6f2ecSGreg Roach 'attribution' => 'Map data ©<a href="https://www.openstreetmap.org">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0">CC-BY-SA</a>', 77c9c6f2ecSGreg Roach 'default' => true, 78c9c6f2ecSGreg Roach 'label' => 'Mapnik', 79c9c6f2ecSGreg Roach 'maxZoom' => 19, 80c9c6f2ecSGreg Roach 'minZoom' => 2, 81c9c6f2ecSGreg Roach 'subdomains' => ['a', 'b', 'c'], 82c9c6f2ecSGreg Roach 'url' => 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 83c9c6f2ecSGreg Roach ], 84c9c6f2ecSGreg Roach (object) [ 85c9c6f2ecSGreg Roach 'attribution' => 'Map data ©<a href="https://www.openstreetmap.org">Karte hergestellt aus OpenStreetMap-Daten</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0">CC-BY-SA</a>', 86c9c6f2ecSGreg Roach 'default' => false, 87c9c6f2ecSGreg Roach 'label' => 'Deutsch', 88c9c6f2ecSGreg Roach 'maxZoom' => 18, 89c9c6f2ecSGreg Roach 'minZoom' => 2, 90c9c6f2ecSGreg Roach 'subdomains' => ['a', 'b', 'c'], 91c9c6f2ecSGreg Roach 'url' => 'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', 92c9c6f2ecSGreg Roach ], 93c9c6f2ecSGreg Roach (object) [ 94c9c6f2ecSGreg Roach 'attribution' => 'Map data ©<a href="https://www.openstreetmap.org">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0">CC-BY-SA</a>', 95c9c6f2ecSGreg Roach 'default' => false, 96c9c6f2ecSGreg Roach 'label' => 'Français', 97c9c6f2ecSGreg Roach 'maxZoom' => 20, 98c9c6f2ecSGreg Roach 'minZoom' => 2, 99c9c6f2ecSGreg Roach 'subdomains' => ['a', 'b', 'c'], 100c9c6f2ecSGreg Roach 'url' => 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', 101c9c6f2ecSGreg Roach ], 102c9c6f2ecSGreg Roach ]; 103c9c6f2ecSGreg Roach } 104c9c6f2ecSGreg Roach} 105