Skip to content

Commit 55f833a

Browse files
authored
feat: v11.x.y enhance window build (#13)
* - use shared files to work on Windows - change Maui.Graphics.Point to GeoJSON.IPosition for location coordinate e.g. mapcenter * - bumb new version * - amend CI/CD * - correct ci/cd script * - trigger fake build * - config download token * - try pass csproj property from cli
1 parent 84a691c commit 55f833a

33 files changed

+138
-98
lines changed

.github/workflows/publish-nuget.yml

+33-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ jobs:
1414
if: ${{ inputs.SHOULD_RUN }}
1515
steps:
1616
- uses: actions/checkout@v3
17-
- name: Set default Xamarin SDK versions
18-
run: |
19-
$VM_ASSETS/select-xamarin-sdk-v2.sh --mono=6.12 --android=13.0
20-
17+
2118
- name: Set .netrc
2219
run: |
2320
echo $NETRC >> ~/.netrc
@@ -26,18 +23,48 @@ jobs:
2623
env:
2724
NETRC : ${{secrets.NETRC}}
2825

29-
- name: Setup .NET Core SDK 7.0.306
26+
- name: Setup .NET Core SDK 8.0
3027
uses: actions/setup-dotnet@v3
3128
with:
32-
dotnet-version: '7.0.306'
29+
dotnet-version: '8.0'
3330

3431
- name: Install ios workload
3532
run: |
3633
dotnet workload install ios android maui maui-ios maui-android
3734
35+
- name: Setup Java 17
36+
uses: actions/setup-java@v3
37+
with:
38+
distribution: 'microsoft'
39+
java-version: '17'
40+
41+
- name: Xcode Select Version
42+
uses: mobiledevops/xcode-select-version-action@v1
43+
with:
44+
xcode-select-version: 15.1
45+
46+
- name: Set MAPBOX_DOWNLOADS_TOKEN
47+
if: contains(${{ inputs.LIB_ARTIFACT }}, 'com.mapbox.maps')
48+
run: |
49+
echo "MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN" >> ~/.gradle/gradle.properties
50+
cat ~/.gradle/gradle.properties
51+
shell: bash
52+
env:
53+
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
54+
55+
- name: Create MauiProgram.dev.cs
56+
run: |
57+
cp src/qs/MapboxMauiQs/MauiProgram.dev.cs.example src/qs/MapboxMauiQs/MauiProgram.dev.cs
58+
59+
# - name: Create MapboxMauiQs.props
60+
# run: |
61+
# echo "${{ secrets.PROJECT_PROPS }}" > src/qs/MapboxMauiQs/MapboxMauiQs.props
62+
3863
- name: Build
3964
run: |
4065
sh build.sh
66+
env:
67+
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}
4168

4269
- name: Publish NuGet and symbols
4370
id: nuget-push

build.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
dotnet nuget locals -c all
2-
dotnet pack -c Release -t:Clean,Rebuild src/libs/Mapbox.Maui/Mapbox.Maui.csproj --output $PWD/nugets
2+
3+
# Build to trigger gradle process
4+
dotnet build -t:Clean,Rebuild src/qs/MapboxMauiQs/MapboxMauiQs.csproj \
5+
-property:MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN
6+
7+
dotnet pack -c Release -t:Clean,Rebuild mapbox-maui.sln --output $PWD/nugets

src/libs/Mapbox.Maui/IMapboxView.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public partial interface IMapboxView : IView
99
{
1010
CameraOptions CameraOptions { get; set; }
1111
MapboxStyle MapboxStyle { get; set; }
12-
Point? MapCenter { get; set; }
12+
IPosition MapCenter { get; set; }
1313
float? MapZoom { get; set; }
1414

1515
OrnamentVisibility ScaleBarVisibility { get; set; }
@@ -58,7 +58,7 @@ public interface IAnnotationController
5858

5959
public interface IMapFeatureQueryable
6060
{
61-
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options);
61+
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options);
6262
}
6363

6464
public class MapTappedEventArgs : EventArgs

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<Target Name="_CleanAarOutputPath" AfterTargets="_CreateAar" BeforeTargets="_IncludeAarInNuGetPackage">
3+
<Delete Files="$(_AarOutputPath)" />
4+
</Target>
25

36
<PropertyGroup>
47
<TargetFrameworks>net8.0-android;net8.0-ios;</TargetFrameworks>
@@ -44,7 +47,7 @@
4447
<RepositoryUrl>https://github.com/tuyen-vuduc/mapbox-maui</RepositoryUrl>
4548
<PackageProjectUrl>https://mapbox.tuyen-vuduc.tech</PackageProjectUrl>
4649
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
47-
<PackageVersion>11.3.0-alpha01</PackageVersion>
50+
<PackageVersion>11.3.0-alpha02</PackageVersion>
4851
<PackageReadmeFile>README.md</PackageReadmeFile>
4952
<PackageLicenseFile>LICENSE</PackageLicenseFile>
5053
<PackageIcon>tv-mapbox.png</PackageIcon>

src/libs/Mapbox.Maui/MapboxView.Events.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public ICommand MapLoadedCommand
120120

121121
public class MapTappedPosition
122122
{
123-
public Point ScreenPosition { get; set; }
123+
public ScreenPosition ScreenPosition { get; set; }
124124

125125
public GeoJSON.Text.Geometry.Point Point { get; set; }
126126
}

src/libs/Mapbox.Maui/MapboxView.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ public CameraOptions CameraOptions
119119

120120
public static readonly BindableProperty MapCenterProperty = BindableProperty.Create(
121121
nameof(MapCenter),
122-
typeof(Point?),
122+
typeof(IPosition),
123123
typeof(MapboxView),
124-
default(Point?)
124+
default(IPosition)
125125
);
126-
public Point? MapCenter
126+
public IPosition MapCenter
127127
{
128128
get => CameraOptions.Center;
129129
set => CameraOptions = CameraOptions with
@@ -149,11 +149,11 @@ public Thickness? MapPadding
149149

150150
public static readonly BindableProperty MapAnchorProperty = BindableProperty.Create(
151151
nameof(MapAnchor),
152-
typeof(Point?),
152+
typeof(ScreenPosition?),
153153
typeof(MapboxView),
154-
default(Point?)
154+
default(ScreenPosition?)
155155
);
156-
public Point? MapAnchor
156+
public ScreenPosition? MapAnchor
157157
{
158158
get => CameraOptions.Anchor;
159159
set => CameraOptions = CameraOptions with

src/libs/Mapbox.Maui/Models/CameraOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
public record struct CameraOptions
44
{
5-
public Point? Center { get; set; }
5+
public IPosition Center { get; set; }
66
public Thickness? Padding { get; set; }
7-
public Point? Anchor { get; set; }
7+
public ScreenPosition? Anchor { get; set; }
88
public float? Zoom { get; set; }
99
public float? Bearing { get; set; }
1010
public float? Pitch { get; set; }

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions)
311311
{
312312
var cameraOptionsBuilder = new MapboxMapsCameraOptions.Builder();
313313

314-
if (cameraOptions.Center.HasValue)
314+
if (cameraOptions.Center is not null)
315315
{
316316
cameraOptionsBuilder.Center(
317317
Com.Mapbox.Geojson.Point.FromLngLat(
318-
cameraOptions.Center.Value.Y,
319-
cameraOptions.Center.Value.X
318+
cameraOptions.Center.Longitude,
319+
cameraOptions.Center.Latitude
320320
));
321321
}
322322

@@ -345,7 +345,7 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions)
345345
));
346346
}
347347

348-
if (cameraOptions.Anchor.HasValue)
348+
if (cameraOptions.Anchor is not null)
349349
{
350350
cameraOptionsBuilder.Anchor(new ScreenCoordinate(
351351
cameraOptions.Anchor.Value.X,

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ internal static MapTappedPosition ToMapTappedPosition(this Com.Mapbox.Geojson.Po
1717
{
1818
return new MapTappedPosition
1919
{
20-
ScreenPosition = new Point(
20+
ScreenPosition = new ScreenPosition(
2121
screenCoordinate.GetX().PixelToPoint(),
2222
screenCoordinate.GetY().PixelToPoint()),
2323
Point = new GeoJSON.Text.Geometry.Point(
24-
new GeoJSON.Text.Geometry.Position(
25-
point.Latitude(),
26-
point.Longitude(),
27-
point.HasAltitude ? point.Altitude() : null
24+
new Position(
25+
screenCoordinate.GetX().PixelToPoint(),
26+
screenCoordinate.GetY().PixelToPoint(),
27+
point.HasAltitude ? point.Altitude() : null)
2828
)
29-
)
3029
};
3130
}
3231

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@
77

88
partial class MapboxViewHandler : IMapFeatureQueryable
99
{
10-
public Task<IEnumerable<XQueriedFeature>> QueryRenderedFeaturesWith(Point point, XRenderedQueryOptions options)
10+
public Task<IEnumerable<XQueriedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, XRenderedQueryOptions options)
1111
{
1212
var mapView = PlatformView.GetMapView();
1313
if (mapView == null) return Task.FromResult(
1414
Array.Empty<XQueriedFeature>() as IEnumerable<XQueriedFeature>
1515
);
1616

1717
var tcs = new TaskCompletionSource<IEnumerable<XQueriedFeature>>();
18-
var pixel = mapView.MapboxMap.PixelForCoordinate(
19-
Com.Mapbox.Geojson.Point.FromLngLat(point.Y, point.X)
20-
);
2118
_ = mapView.MapboxMap.QueryRenderedFeatures(
2219
new RenderedQueryGeometry(
2320
new ScreenBox(
24-
new ScreenCoordinate(pixel.GetX() - 25.0, pixel.GetY() - 25.0),
25-
new ScreenCoordinate(pixel.GetX() + 25.0, pixel.GetY() + 25.0)
21+
new ScreenCoordinate(point.X - 25.0, point.Y - 25.0),
22+
new ScreenCoordinate(point.X + 25.0, point.Y + 25.0)
2623
)
2724
),
2825
options.ToPlatform(),

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,10 @@ public static IList<MBMMapDebugOptions> ToNative(this IEnumerable<DebugOption> o
266266

267267
public static TMBCameraOptions ToNative(this CameraOptions cameraOptions)
268268
{
269-
CLLocationCoordinate2D center = cameraOptions.Center.HasValue
270-
? new CLLocationCoordinate2D(cameraOptions.Center.Value.X, cameraOptions.Center.Value.Y)
269+
CLLocationCoordinate2D center = cameraOptions.Center is not null
270+
? new CLLocationCoordinate2D(
271+
cameraOptions.Center.Latitude,
272+
cameraOptions.Center.Longitude)
271273
: new CLLocationCoordinate2D(0, 0);
272274
UIKit.UIEdgeInsets padding = cameraOptions.Padding.HasValue
273275
? new UIKit.UIEdgeInsets(
@@ -276,7 +278,7 @@ public static TMBCameraOptions ToNative(this CameraOptions cameraOptions)
276278
(float)cameraOptions.Padding.Value.Bottom,
277279
(float)cameraOptions.Padding.Value.Right)
278280
: UIKit.UIEdgeInsets.Zero;
279-
var anchor = cameraOptions.Anchor.HasValue
281+
var anchor = cameraOptions.Anchor is not null
280282
? new CoreGraphics.CGPoint(
281283
cameraOptions.Anchor.Value.X,
282284
cameraOptions.Anchor.Value.Y

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using CoreGraphics;
22
using CoreLocation;
33
using Foundation;
4-
using GeoJSON.Text.Feature;
5-
using GeoJSON.Text.Geometry;
64
using MapboxCommon;
7-
using MapboxCoreMaps;
85
using MapboxMapsObjC;
96

107
namespace MapboxMaui;
@@ -15,12 +12,12 @@ internal static MapTappedPosition ToMapTappedPosition(this CLLocationCoordinate2
1512
{
1613
return new MapTappedPosition
1714
{
18-
ScreenPosition = new Microsoft.Maui.Graphics.Point(
15+
ScreenPosition = new ScreenPosition(
1916
screenCoordinate.X,
2017
screenCoordinate.Y
2118
),
2219
Point = new GeoJSON.Text.Geometry.Point(
23-
new GeoJSON.Text.Geometry.Position(
20+
new Position(
2421
coords.Latitude,
2522
coords.Longitude
2623
)

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
using MapboxMaui.Query;
44
using MapboxMapsObjC;
55
using Foundation;
6+
using CoreGraphics;
67

78
partial class MapboxViewHandler : IMapFeatureQueryable
89
{
9-
public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options)
10+
public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options)
1011
{
1112
var mapView = PlatformView.MapView;
1213
if (mapView == null) return Task.FromResult(
@@ -15,7 +16,8 @@ public Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(Point
1516

1617
var tcs = new TaskCompletionSource<IEnumerable<QueriedRenderedFeature>>();
1718

18-
_ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(point, options.ToPlatform(), (features, error) => {
19+
var xpoint = new CGPoint(point.X, point.Y);
20+
_ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(xpoint, options.ToPlatform(), (features, error) => {
1921
if (error != null) {
2022
tcs.TrySetException(new NSErrorException(error));
2123
return;
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
global using System;
2-
global using System.Text.Json;
1+
global using System.Text.Json;
32
global using GeoJSON.Text;
43
global using GeoJSON.Text.Feature;
54
global using GeoJSON.Text.Geometry;
6-
global using Point = Microsoft.Maui.Graphics.Point;
75
global using MapboxMaui;
86
global using MapboxMaui.Expressions;
97
global using MapboxMaui.Styles;
108
global using MapboxMaui.Offline;
119
global using MapboxMaui.Annotations;
12-
global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page;
10+
global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page;
11+
global using ScreenPosition = Microsoft.Maui.Graphics.Point;

src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void ApplyQueryAttributes(IDictionary<string, object> query)
3434

3535
private void Map_MapReady(object sender, EventArgs e)
3636
{
37-
var centerLocation = new Point(55.70651, 12.554729);
37+
var centerLocation = new Position(55.70651, 12.554729);
3838
var cameraOptions = new CameraOptions
3939
{
4040
Center = centerLocation,

src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private void Map_StyleLoaded(object sender, EventArgs e)
4343
private void Map_MapReady(object sender, EventArgs e)
4444
{
4545
// Do any additional setup after loading the view.
46-
var center = new Point(55.665957, 12.550343);
46+
var center = new Position(55.665957, 12.550343);
4747
var cameraOptions = new CameraOptions {
4848
Center = center,
4949
Zoom = 8,

src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExample.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static class Constants
1212
MapboxView map;
1313
IExampleInfo info;
1414

15-
private Point currentPosition = new Point(64.900932, -18.167040);
15+
private IPosition currentPosition = new Position(64.900932, -18.167040);
1616

1717
public AnimatedMarkerExample()
1818
{
@@ -66,9 +66,7 @@ private void Map_MapLoaded(object sender, EventArgs e)
6666

6767
// Create a GeoJSON data source.
6868
var feature = new Feature(
69-
new GeoJSON.Text.Geometry.Point(
70-
new Position(currentPosition.X, currentPosition.Y)
71-
)
69+
new GeoJSON.Text.Geometry.Point(currentPosition)
7270
);
7371
var source = new GeoJSONSource(Constants.sourceId)
7472
{

src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ContentPage
33
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
44
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
5-
xmlns:mb="clr-namespace:MapboxMaui;assembly=Mapbox.Maui"
5+
xmlns:mb="clr-namespace:MapboxMaui"
66
x:Class="MapboxMauiQs.BasicMapExample"
77
Title="BasicMapExample">
88
<mb:MapboxView

src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private void Map_MapReady(object sender, EventArgs e)
1818
map.MapboxStyle = MapboxStyle.STANDARD;
1919
map.CameraOptions = new CameraOptions
2020
{
21-
Center = new Point(21.028511, 105.804817),
21+
Center = new Position(21.028511, 105.804817),
2222
Zoom = 9,
2323
};
2424
}

src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExample.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void Map_StyleLoaded(object sender, EventArgs e)
120120
layer,
121121
};
122122

123-
var center = new Point(40.7135, -74.0066);
123+
var center = new Position(40.7135, -74.0066);
124124
var cameraOptions = new CameraOptions
125125
{
126126
Center = center,

0 commit comments

Comments
 (0)