-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- assign CameraOptions and Style at creation
- Loading branch information
1 parent
3f14345
commit 9e56ab6
Showing
10 changed files
with
124 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
namespace MapboxMaui; | ||
|
||
public record struct CameraOptions | ||
public partial record struct CameraOptions | ||
{ | ||
public IPosition Center { get; set; } | ||
public Thickness? Padding { get; set; } | ||
public ScreenPosition? Anchor { get; set; } | ||
public float? Zoom { get; set; } | ||
public float? Bearing { get; set; } | ||
public float? Pitch { get; set; } | ||
} | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
src/libs/Mapbox.Maui/Platforms/Android/CameraOptionsParcelable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Android.OS; | ||
using Android.Runtime; | ||
|
||
namespace MapboxMaui; | ||
|
||
internal class CameraOptionsParcelable : Java.Lang.Object, IParcelable | ||
{ | ||
public CameraOptions CameraOptions { get; private set; } | ||
|
||
public CameraOptionsParcelable(CameraOptions cameraOptions) | ||
{ | ||
this.CameraOptions = cameraOptions; | ||
} | ||
|
||
public void WriteToParcel(Parcel dest, [GeneratedEnum] ParcelableWriteFlags flags) | ||
{ | ||
dest.WriteFloat(CameraOptions.Zoom ?? 0); | ||
dest.WriteDouble(CameraOptions.Center.Latitude); | ||
dest.WriteDouble(CameraOptions.Center.Longitude); | ||
dest.WriteFloat(CameraOptions.Bearing ?? 0); | ||
dest.WriteFloat(CameraOptions.Pitch ?? 0); | ||
} | ||
|
||
public int DescribeContents() | ||
{ | ||
return 0; | ||
} | ||
|
||
public static readonly IParcelableCreator CREATOR = new XCreator(); | ||
|
||
class XCreator : Java.Lang.Object, IParcelableCreator | ||
{ | ||
public Java.Lang.Object CreateFromParcel(Parcel source) | ||
{ | ||
var zoom = source.ReadFloat(); | ||
var latitude = source.ReadDouble(); | ||
var longitude = source.ReadDouble(); | ||
var bearing = source.ReadFloat(); | ||
var pitch = source.ReadFloat(); | ||
|
||
var cameraOptions = new CameraOptions | ||
{ | ||
Zoom = zoom, | ||
Center = new MapPosition(latitude, longitude), | ||
Bearing = bearing, | ||
Pitch = pitch, | ||
}; | ||
|
||
return new CameraOptionsParcelable(cameraOptions); | ||
} | ||
|
||
public Java.Lang.Object[] NewArray(int size) | ||
{ | ||
return new CameraOptionsParcelable[size]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters