diff --git a/LICENSE.txt b/LICENSE.txt index 37270ac0..40bfd2e7 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) themronion 2016-2022 +Copyright (c) themronion 2022-2023 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/Maui.GoogleMaps/Handlers/MapHandler.Standard.cs b/lib/Maui.GoogleMaps/Handlers/MapHandler.Standard.cs deleted file mode 100644 index 6217681f..00000000 --- a/lib/Maui.GoogleMaps/Handlers/MapHandler.Standard.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.Maui.Handlers; - -namespace Maui.GoogleMaps.Handlers -{ - public partial class MapHandler : ViewHandler - { - protected override object CreatePlatformView() => throw new NotImplementedException(); - public static void MapMapType(MapHandler handler, Map map) { } - public static void MapPadding(MapHandler handler, Map map) { } - public static void MapIsTrafficEnabled(MapHandler handler, Map map) { } - public static void MapIsIndoorEnabled(MapHandler handler, Map map) { } - public static void MapMyLocationEnabled(MapHandler handler, Map map) { } - public static void MapMapStyle(MapHandler handler, Map map) { } - public static void MapSelectedPin(MapHandler handler, Map map) { } - } -} diff --git a/lib/Maui.GoogleMaps/Hosting/AppHostBuilderExtensions.cs b/lib/Maui.GoogleMaps/Hosting/AppHostBuilderExtensions.cs index 01717bb1..cdfbe985 100644 --- a/lib/Maui.GoogleMaps/Hosting/AppHostBuilderExtensions.cs +++ b/lib/Maui.GoogleMaps/Hosting/AppHostBuilderExtensions.cs @@ -5,13 +5,12 @@ namespace Maui.GoogleMaps.Hosting { public static class AppHostBuilderExtensions { - public static MauiAppBuilder UseGoogleMaps(this MauiAppBuilder appBuilder + public static MauiAppBuilder UseGoogleMaps(this MauiAppBuilder appBuilder, #if ANDROID - , Android.PlatformConfig config = null + Android.PlatformConfig config = null) #elif IOS - , string iosApiKey, iOS.PlatformConfig config = null + string iosApiKey, iOS.PlatformConfig config = null) #endif - ) { appBuilder.ConfigureMauiHandlers(handlers => handlers.AddTransient(typeof(Map), h => new MapHandler())) .ConfigureLifecycleEvents(events => @@ -21,7 +20,7 @@ public static MauiAppBuilder UseGoogleMaps(this MauiAppBuilder appBuilder .OnCreate((activity, bundle) => MauiGoogleMaps.Init(activity, bundle, config))); #elif IOS events.AddiOS(ios => ios - .FinishedLaunching((app, options) => + .WillFinishLaunching((app, options) => { MauiGoogleMaps.Init(iosApiKey, config); return true; diff --git a/lib/Maui.GoogleMaps/Maui.GoogleMaps.csproj b/lib/Maui.GoogleMaps/Maui.GoogleMaps.csproj index 92ccf70a..6da6593b 100644 --- a/lib/Maui.GoogleMaps/Maui.GoogleMaps.csproj +++ b/lib/Maui.GoogleMaps/Maui.GoogleMaps.csproj @@ -1,51 +1,16 @@ - net7.0;net7.0-android;net7.0-ios + net7.0-android;net7.0-ios true true enable 14.2 21.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - false - - - - $(DefineConstants);MONOANDROID - - - - $(DefineConstants);IOS - + @@ -53,5 +18,4 @@ - diff --git a/lib/Xamarin.Forms.GoogleMaps.nuspec b/lib/Xamarin.Forms.GoogleMaps.nuspec index 28961d45..eda044c9 100644 --- a/lib/Xamarin.Forms.GoogleMaps.nuspec +++ b/lib/Xamarin.Forms.GoogleMaps.nuspec @@ -3,16 +3,16 @@ Onion.Maui.GoogleMaps Maui.GoogleMaps - 5.0.0 + 5.0.1 -# 5.0.0 +# 5.0.1 -- Built with net7.0 -- Removed Xamarin Forms support +- Removed net7.0 target (only android and ios left) +- Reconfigure map initialization to be able to use it on the first page - Dependencies update themronion - Copyright 2016-2022 + Copyright 2022-2023 LICENSE.txt https://github.com/themronion/Maui.GoogleMaps/tree/maui false @@ -20,10 +20,8 @@ Maps library for MAUI that is optimized for Google maps maui maps mauimaps maui.maps mauigooglemaps maui.googlemaps google googlemap - - - + @@ -36,7 +34,6 @@ - diff --git a/lib/build.bat b/lib/build.bat deleted file mode 100644 index e93cf357..00000000 --- a/lib/build.bat +++ /dev/null @@ -1,5 +0,0 @@ -nuget restore ../Xamarin.Forms.GoogleMaps.sln - -msbuild ../Xamarin.Forms.GoogleMaps.sln /t:Clean;Build /p:Configuration=Release - -nuget pack diff --git a/sample/MauiGoogleMapSample/BasicMapPage.xaml.cs b/sample/MauiGoogleMapSample/BasicMapPage.xaml.cs index 47aa750d..b8a95a67 100644 --- a/sample/MauiGoogleMapSample/BasicMapPage.xaml.cs +++ b/sample/MauiGoogleMapSample/BasicMapPage.xaml.cs @@ -23,9 +23,26 @@ public BasicMapPage() pickerMapType.SelectedIndex = 0; // MyLocationEnabled - switchMyLocationEnabled.Toggled += (sender, e) => + switchMyLocationEnabled.Toggled += async (sender, e) => { - map.MyLocationEnabled = e.Value; + if (e.Value) + { + var status = await CheckAndRequestLocationPermission(); + if (status == PermissionStatus.Granted) + { + map.MyLocationEnabled = e.Value; + await DisplayAlert("Location", "Please be aware, that GEO needs to be on to make this work", "OK"); + } + else + { + await DisplayAlert("Permission", "Failed due to permission error", "OK"); + switchMyLocationEnabled.IsToggled = false; + } + } + else + { + map.MyLocationEnabled = e.Value; + } }; switchMyLocationEnabled.IsToggled = map.MyLocationEnabled; @@ -164,6 +181,29 @@ public BasicMapPage() imageSnapshot.Source = ImageSource.FromStream(() => stream); }; } + + public async Task CheckAndRequestLocationPermission() + { + PermissionStatus status = await Permissions.CheckStatusAsync(); + + if (status == PermissionStatus.Granted) + return status; + + if (status == PermissionStatus.Denied && DeviceInfo.Platform == DevicePlatform.iOS) + { + await DisplayAlert("Permission", "Please give location permission in settings", "OK"); + return status; + } + + if (Permissions.ShouldShowRationale()) + { + await DisplayAlert("Permission", "Permission needed to turn on geo", "OK"); + } + + status = await Permissions.RequestAsync(); + + return status; + } } }