Skip to content

Commit 2922320

Browse files
committed
- align with new native APIs for iOS
1 parent 6b027d1 commit 2922320

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

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

+2-2
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.5.0-alpha03</PackageVersion>
64+
<PackageVersion>11.5.1-alpha01</PackageVersion>
6565
<PackageReadmeFile>README.md</PackageReadmeFile>
6666
<PackageLicenseFile>LICENSE</PackageLicenseFile>
6767
<PackageIcon>tv-mapbox.png</PackageIcon>
@@ -94,7 +94,7 @@
9494
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.8.0.1" />
9595
</ItemGroup>
9696
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
97-
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.5.2" />
97+
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.5.2.2" />
9898
<PackageReference Include="MapboxMaps.iOS" Version="11.5.2" />
9999
</ItemGroup>
100100
<ItemGroup>

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,15 @@ private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxV
293293

294294
mapView.MapboxMap().LoadStyleWithUri(styleUri, null, (error) =>
295295
{
296-
if (error == null) return;
296+
if (error is not null)
297+
{
298+
System.Diagnostics.Debug.WriteLine(error.LocalizedDescription);
299+
return;
300+
}
301+
302+
if (handler.VirtualView is not MapboxView mapboxView) return;
297303

298-
System.Diagnostics.Debug.WriteLine(error.LocalizedDescription);
304+
mapboxView.InvokeStyleLoaded();
299305
});
300306
}
301307

src/libs/Mapbox.Maui/Platforms/iOS/Viewport/ViewportExtensions.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using MapboxMapsObjC;
2+
using ObjCRuntime;
23
using X = MapboxMaui.Viewport;
34

45
namespace MapboxMaui;
@@ -112,12 +113,16 @@ public static TMBOverviewViewportStateOptions ToNative(
112113
}
113114

114115
public static X.IViewportState ToX(this ITMBViewportState state)
115-
=> state switch
116+
{
117+
try
116118
{
117-
TMBFollowPuckViewportState followPuckViewportState => followPuckViewportState.ToX(),
118-
TMBOverviewViewportState overviewViewportState => overviewViewportState.ToX(),
119-
_ => throw new NotSupportedException("Invalid ViewportState"),
120-
};
119+
return Runtime.GetNSObject<TMBOverviewViewportState>(state.Handle).ToX();
120+
}
121+
catch
122+
{
123+
return Runtime.GetNSObject<TMBFollowPuckViewportState>(state.Handle).ToX();
124+
}
125+
}
121126
public static X.IFollowPuckViewportState ToX(this TMBFollowPuckViewportState state)
122127
=> new XFollowPuckViewPortState(state);
123128
public static X.IOverviewViewportState ToX(this TMBOverviewViewportState state)

src/qs/MapboxMauiQs/Examples/Camera/69.AdvancedViewportGestures/AdvancedViewportGesturesExample.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public AdvancedViewportGesturesExample()
2424

2525
map.MapReady += Map_MapReady;
2626
map.MapLoaded += Map_MapLoaded;
27-
map.StyleLoaded += Map_StyleLoaded;
2827
}
2928

3029
public void ApplyQueryAttributes(IDictionary<string, object> query)
@@ -44,8 +43,6 @@ private async void Map_MapReady(object sender, EventArgs e)
4443
//};
4544

4645
//map.CameraOptions = cameraOptions;
47-
map.MapboxStyle = MapboxStyle.TRAFFIC_DAY;
48-
4946
followPuckViewportState = map.Viewport.MakeFollowPuckViewportState(new FollowPuckViewportStateOptions
5047
{
5148
Bearing = 0,
@@ -73,6 +70,10 @@ private async void Map_MapReady(object sender, EventArgs e)
7370
};
7471
map.Sources = [geojsonSource];
7572
map.Layers = [lineLayer];
73+
74+
map.StyleLoaded += Map_StyleLoaded;
75+
map.MapboxStyle = MapboxStyle.TRAFFIC_DAY;
76+
7677
}
7778

7879
private void Map_MapTapped(object sender, MapTappedEventArgs e)

src/qs/MapboxMauiQs/MapboxMauiQs.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
</Compile>
107107
</ItemGroup>
108108
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
109-
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.5.2" />
109+
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.5.2.2" />
110110
<PackageReference Include="MapboxMaps.iOS" Version="11.5.2" />
111111

112112
<Compile Include="..\..\libs\Mapbox.Maui\Platforms\iOS\**\**\*.cs">

0 commit comments

Comments
 (0)