Skip to content

Commit 00c04dc

Browse files
committed
fix: ScaleBarVisibility for Android
1 parent 7f5dc68 commit 00c04dc

7 files changed

+10
-14
lines changed

src/libs/Mapbox.Maui/Mapbox.Maui.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<RepositoryUrl>https://github.com/tuyen-vuduc/mapbox-maui</RepositoryUrl>
6262
<PackageProjectUrl>https://mapbox.tuyen-vuduc.tech</PackageProjectUrl>
6363
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
64-
<PackageVersion>11.6.0-alpha01</PackageVersion>
64+
<PackageVersion>11.6.0-alpha02</PackageVersion>
6565
<PackageReadmeFile>README.md</PackageReadmeFile>
6666
<PackageLicenseFile>LICENSE</PackageLicenseFile>
6767
<PackageIcon>tv-mapbox.png</PackageIcon>

src/libs/Mapbox.Maui/MapboxView.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public DebugOption[] DebugOptions
101101
nameof(ScaleBarVisibility),
102102
typeof(OrnamentVisibility),
103103
typeof(MapboxView),
104-
OrnamentVisibility.Hidden
104+
OrnamentVisibility.Visible
105105
);
106106
public OrnamentVisibility ScaleBarVisibility
107107
{

src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Com.Mapbox.Maps.Plugins.Animation;
1717
using Com.Mapbox.Functions;
1818
using Com.Mapbox.Maps.Plugins;
19+
using System.ComponentModel;
1920

2021
static class AdditionalExtensions
2122
{
@@ -313,13 +314,10 @@ internal static PlatformValue GetVolatileProperties(this MapboxSource source)
313314
}
314315

315316
internal static MapView GetMapView(this MapboxViewHandler handler)
316-
=> handler.PlatformView.GetMapView();
317-
318-
internal static MapView GetMapView(this FragmentContainerView container)
319317
{
320-
var mainActivity = (MauiAppCompatActivity)container.Context.GetActivity();
321-
var tag = $"mapbox-maui-{container.Id}";
322-
var fragnent = mainActivity.SupportFragmentManager.FindFragmentByTag(tag);
318+
var fragmentManager = handler.MauiContext.Services.GetService<FragmentManager>();
319+
var tag = $"mapbox-maui-{handler.PlatformView.Id}";
320+
var fragnent = fragmentManager.FindFragmentByTag(tag);
323321
return (fragnent as MapboxFragment)?.MapView;
324322
}
325323

src/libs/Mapbox.Maui/Platforms/Android/MapboxFragment.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
5959
}
6060

6161
MapView = new MapView(Context);
62-
63-
MapReady?.Invoke(MapView);
6462
return MapView;
6563
}
6664

6765
public override void OnViewCreated(View view, Bundle savedInstanceState)
6866
{
6967
base.OnViewCreated(view, savedInstanceState);
7068

69+
MapReady?.Invoke(MapView);
70+
7171
cancelables.Add(
7272
MapView.MapboxMap.SubscribeCameraChanged(this)
7373
);

src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Location.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public partial class MapboxViewHandler : Locations.ILocationComponentPlugin
77
{
88
private ILocationComponentPlugin GetPlugin()
99
{
10-
var mapView = PlatformView.GetMapView();
10+
var mapView = this.GetMapView();
1111
if (mapView is null) return null;
1212

1313
return LocationComponentUtils.GetLocationComponent(mapView);

src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Query.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ partial class MapboxViewHandler : IMapFeatureQueryable
99
{
1010
public Task<IEnumerable<XQueriedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, XRenderedQueryOptions options)
1111
{
12-
var mapView = PlatformView.GetMapView();
12+
var mapView = this.GetMapView();
1313
if (mapView == null) return Task.FromResult(
1414
Array.Empty<XQueriedFeature>() as IEnumerable<XQueriedFeature>
1515
);

src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs

-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,6 @@ private static void HandleScaleBarVisibilityChanged(MapboxViewHandler handler, I
212212
var mapView = handler.GetMapView();
213213
if (mapView is null) return;
214214

215-
if (mapView.MapboxMap.Style?.IsStyleLoaded != true) return;
216-
217215
var scaleBarPlugin = ScaleBarUtils.GetScaleBar(mapView);
218216

219217
scaleBarPlugin.Enabled = view.ScaleBarVisibility != OrnamentVisibility.Hidden;

0 commit comments

Comments
 (0)