Skip to content

Commit

Permalink
Feature: Show route to venue if own location is set
Browse files Browse the repository at this point in the history
  • Loading branch information
axunonb committed Sep 17, 2024
1 parent 7b9b93f commit 1a7ab63
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,23 @@ public string GetVenueGoogleMapsLink()
if (!(Longitude.HasValue && Latitude.HasValue))
return string.Empty;

if (_userLocation.IsSet)
{
return string.Format("https://maps.google.de/maps?saddr={0},{1}&daddr={2},{3}",
_userLocation.Latitude!.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
_userLocation.Longitude!.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
Latitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
Longitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture));
}

return string.Format("https://maps.google.de?q={0},{1}",
Latitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
Longitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture));
}

public string GetRouteGoogleMapsLink()
{
if (!IsGeoSpatial())
return string.Empty;

return string.Format("https://maps.google.de/maps?saddr={0},{1}&daddr={2},{3}",
_userLocation.Latitude!.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
_userLocation.Longitude!.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),
Latitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture),

Check warning on line 146 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 146 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 146 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 146 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.
Longitude.Value.ToString(LatLonFormat, CultureInfo.InvariantCulture));

Check warning on line 147 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 147 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 147 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.

Check warning on line 147 in Src/TournamentCalendar/Models/Calendar/CalendarEntityDisplayModel.cs

View workflow job for this annotation

GitHub Actions / build

Nullable value type may be null.
}

public bool IsGeoSpatial()
{
return Longitude.HasValue && Latitude.HasValue && _userLocation.IsSet;
Expand Down
7 changes: 3 additions & 4 deletions Src/TournamentCalendar/TournamentCalendar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<PropertyGroup>
<Product>TournamentCalendar</Product>
<TargetFramework>net8.0</TargetFramework>
<Version>4.2.1</Version>
<FileVersion>4.2.1</FileVersion>
<Version>4.3.2</Version>
<FileVersion>4.3.2</FileVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion><!--only update AssemblyVersion with major releases -->
<EnableDefaultContentItems>true</EnableDefaultContentItems>
<Authors>axuno gGmbH</Authors>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
Expand All @@ -12,8 +13,6 @@
<Nullable>enable</Nullable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>TournamentCalender-192x192.png</PackageIcon>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<!--only update AssemblyVersion with major releases -->
<LangVersion>latest</LangVersion>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,14 @@
{
<div class="rounded pb-3 col-12 shadow">
<div class="py-2">
<a href="@Model.GetVenueGoogleMapsLink()" class="link" title="Route auf Google Maps Website anzeigen" target="_blank">Karte auf Google Maps Website anzeigen</a>
@if (Model.IsGeoSpatial())
{
<a href="@Model.GetRouteGoogleMapsLink()" title="Route auf Google Maps Website anzeigen" target="_blank"><i class="bi bi-record2-fill"></i><i class="bi bi-arrow-right"></i><i class="bi bi-record2-fill"></i> <b>Route auf Google Maps Website anzeigen</b></a>
}
else
{
<a href="@Model.GetVenueGoogleMapsLink()" title="Karte auf Google Maps Website anzeigen" target="_blank"><i class="bi bi-record2-fill"></i> Karte auf Google Maps Website anzeigen</a>
}
</div>
<div id="mapPlaceholder" class="rounded" style="border: 1px solid #979797; background-color: #e5e3df; width: 100%; height: 400px">
<div style="padding: 1rem; color: gray">
Expand Down

0 comments on commit 1a7ab63

Please sign in to comment.