-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
map providers are now specified in an Enum (#2033)
- Loading branch information
Showing
5 changed files
with
73 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
/** | ||
* Define the possible Map providers and their layer & attributions. | ||
* (will be used later in Livewire). | ||
*/ | ||
enum MapProviders: string | ||
{ | ||
case Wikimedia = 'Wikimedia'; | ||
case OpenStreetMapOrg = 'OpenStreetMap.org'; | ||
case OpenStreetMapDe = 'OpenStreetMap.de'; | ||
case OpenStreetMapFr = 'OpenStreetMap.fr'; | ||
case RRZE = 'RRZE'; | ||
|
||
public function getLayer(): string | ||
{ | ||
return match ($this) { | ||
self::Wikimedia => 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png', | ||
self::OpenStreetMapOrg => 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
self::OpenStreetMapDe => 'https://tile.openstreetmap.de/{z}/{x}/{y}.png ', | ||
self::OpenStreetMapFr => 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png ', | ||
self::RRZE => 'https://{s}.osm.rrze.fau.de/osmhd/{z}/{x}/{y}.png', | ||
}; | ||
} | ||
|
||
public function getAtributionHtml(): string | ||
{ | ||
return match ($this) { | ||
self::Wikimedia => '<a href="https://wikimediafoundation.org/wiki/Maps_Terms_of_Use">Wikimedia</a>', | ||
self::OpenStreetMapOrg => '© <a href="https://openstreetmap.org/copyright">' . __('lychee.OSM_CONTRIBUTORS') . '</a>', | ||
self::OpenStreetMapDe => '© <a href="https://openstreetmap.org/copyright">' . __('lychee.OSM_CONTRIBUTORS') . '</a>', | ||
self::OpenStreetMapFr => '© <a href="https://openstreetmap.org/copyright">' . __('lychee.OSM_CONTRIBUTORS') . '</a>', | ||
self::RRZE => '© <a href="https://openstreetmap.org/copyright">' . __('lychee.OSM_CONTRIBUTORS') . '</a>', | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
database/migrations/2023_10_01_143159_config_map_provider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
return new class() extends Migration { | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
DB::table('configs')->where('key', '=', 'map_provider')->update(['type_range' => 'map_provider']); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
DB::table('configs')->where('key', '=', 'map_provider')->update(['type_range' => 'Wikimedia|OpenStreetMap.org|OpenStreetMap.de|OpenStreetMap.fr|RRZE']); | ||
} | ||
}; |