Skip to content

Commit

Permalink
- check and fix iOS binding
Browse files Browse the repository at this point in the history
  • Loading branch information
tuyen-vuduc committed Aug 14, 2024
1 parent 8004443 commit 10d8004
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/libs/Mapbox.Maui/IMapboxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ public interface IMapboxController
CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions);
ScreenPosition GetScreenPosition(IPosition position);
CameraOptions? CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
CameraOptions? cameraOptions = default,
Thickness? coordinatesPadding = default,
double? maxZoom = default,
ScreenPosition? offset = default
);
void CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
Action<CameraOptions?> completion,
CameraOptions? cameraOptions = default,
Thickness? coordinatesPadding = default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ScreenPosition GetScreenPosition(IPosition position)
* Also empty [CameraOptions] are returned in case of an internal error.
*/
public CameraOptions? CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
CameraOptions? cameraOptions = null,
Thickness? coordinatesPadding = null,
double? maxZoom = null,
Expand All @@ -71,7 +71,7 @@ public ScreenPosition GetScreenPosition(IPosition position)

var result = mapView.MapboxMap.CameraForCoordinates(
coordinates?.Select(x => x.ToGeoPoint()).ToList(),
cameraOptions?.ToNative(),
(cameraOptions?? new()).ToNative(),
coordinatesPadding?.ToNative(),
maxZoom?.ToNative(),
offset?.ToScreenCoordinate()
Expand All @@ -91,7 +91,7 @@ public ScreenPosition GetScreenPosition(IPosition position)
* @param completion Callback returning the [CameraOptions] object representing the provided parameters. Those [CameraOptions] always take into account actual MapView size and may return empty ([CameraOptions.isEmpty]) options only if an internal error has occurred.
*/
public void CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
Action<CameraOptions?> completion,
CameraOptions? cameraOptions = null,
Thickness? coordinatesPadding = null,
Expand All @@ -108,7 +108,7 @@ public void CameraForCoordinates(

mapView.MapboxMap.CameraForCoordinates(
coordinates?.Select(x => x.ToGeoPoint()).ToList(),
cameraOptions?.ToNative(),
(cameraOptions??new()).ToNative(),
coordinatesPadding?.ToNative(),
maxZoom?.ToNative(),
offset?.ToScreenCoordinate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ScreenPosition GetScreenPosition(IPosition position)
* Also empty [CameraOptions] are returned in case of an internal error.
*/
public CameraOptions? CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
CameraOptions? cameraOptions = null,
Thickness? coordinatesPadding = null,
double? maxZoom = null,
Expand All @@ -73,7 +73,7 @@ public ScreenPosition GetScreenPosition(IPosition position)
TMBCameraOptions? xresult = null;

Check warning on line 73 in src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs

View workflow job for this annotation

GitHub Actions / build-then-publish

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
mapView.MapboxMap().CameraFor(
coordinates?.Select(x => x.ToNSValue()).ToArray(),
cameraOptions?.ToNative(),
(cameraOptions?? new()).ToNative(),
coordinatesPadding?.ToNSValue(),
maxZoom?.ToNSNumber(),
offset?.ToNSValue(),
Expand All @@ -96,7 +96,7 @@ public ScreenPosition GetScreenPosition(IPosition position)
* @param completion Callback returning the [CameraOptions] object representing the provided parameters. Those [CameraOptions] always take into account actual MapView size and may return empty ([CameraOptions.isEmpty]) options only if an internal error has occurred.
*/
public void CameraForCoordinates(
IEnumerable<MapPosition> coordinates,
IEnumerable<IPosition> coordinates,
Action<CameraOptions?> completion,
CameraOptions? cameraOptions = null,
Thickness? coordinatesPadding = null,
Expand All @@ -114,7 +114,7 @@ public void CameraForCoordinates(

mapView.MapboxMap().CameraFor(
coordinates?.Select(x => x.ToNSValue()).ToArray(),
cameraOptions?.ToNative(),
(cameraOptions?? new()).ToNative(),
coordinatesPadding?.ToNSValue(),
maxZoom?.ToNSNumber(),
offset?.ToNSValue(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using MapboxMaui;

namespace MapboxMauiQs;

public class BasicLocationPulsingCircleExample : ContentPage, IExamplePage, IQueryAttributable
Expand Down Expand Up @@ -33,7 +35,8 @@ private async void OpenSettings(object obj)
? "Hide user location" : "Show user location",
map.LocationComponent.PulsingEnabled
? "Hide pulsing" : "Show pulsing",
"Show accuracy ring"
"Show accuracy ring",
"Change map style"
);

switch (action) {
Expand All @@ -48,6 +51,9 @@ private async void OpenSettings(object obj)
case "Show accuracy ring":
ShowPulsingAccuracyRing(action);
break;
case "Change map style":
ToggleMapboxStyle(action);
break;
}
}

Expand Down Expand Up @@ -118,5 +124,17 @@ private void Map_IndicatorPositionChanged(object sender, IndicatorPositionChange
{
FocalPoint = map.MapboxController.GetScreenPosition(e.Position),
};

// var bounds = map.MapboxController.GetCoordinateBoundsForCamera(map.CameraController.CameraState);
// IEnumerable<IPosition> coords = new IPosition[] {
// bounds.Southwest.ToPoint().Coordinates,
// bounds.Northeast.ToPoint().Coordinates
// };
// map.MapboxController.CameraForCoordinates(
// coords
// , completion: (x) =>
// {

// });
}
}

0 comments on commit 10d8004

Please sign in to comment.