Skip to content

Commit a75786b

Browse files
authored
feat: v11.5.0-alpha01 (#30)
* - fix for Android * - change btns style * - add MapLoadingError (iOS only) * - use latest Mapbox Android SDK * - use latest iOS SDK v11.5.1 - use new functions to add/remove annotations for iOS * - correct build script * - correct build script
1 parent 0f38649 commit a75786b

21 files changed

+373
-172
lines changed

README.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,27 @@ NOTE: A handy command to generate a new example
117117
dotnet cake -- --name SymbolClustering --index 58 --group Annotations --title "Add Cluster Symbol Annotations" --subtitle "Show fire hydrants in Washington DC area in a cluster using a symbol layer."
118118
````
119119
120-
# Known issues
121-
- The library is not yet able to build to run on iOS real device. [Issue](https://github.com/xamarin/xamarin-macios/issues/8917)
120+
# NOTES
121+
122+
1) Failed to delete `.gradle` folder
123+
Due to Java process not killed gratefully.
124+
```
125+
taskkill -F -im java.exe
126+
```
127+
128+
2) Xamarin.Build.Download
129+
Xamarin.Build.Download is a tool to help download artifacts from remote URL to avoid embedding the native artifacts within the NuGet package with advantages
130+
- Very thin and lightweight NuGet package
131+
- Avoid any license viloation if the owner of the native lib doesn't want us to redistribute their lib
132+
133+
The downloaded artifact will be located at
134+
- MacOS: `~/Library/Caches/XamarinBuildDownload`
135+
- Windows: `%USERPROFILE%/AppData/Local/XamarinBuildDownloadCache`
136+
137+
3) Kill all .NET processes
138+
```
139+
taskkill -F -im dotnet.exe
140+
```
122141
123142
# Maintainer
124143
This project is maintained by [tuyen-vuduc](https://github.com/tuyen-vuduc) in his spare time and/or when requested.<br>

build.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
dotnet nuget locals -c all
1+
# dotnet nuget locals -c all
22

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 src/libs/Mapbox.Maui/Mapbox.Maui.csproj \
8-
--output $PWD/nugets
3+
# Add this option to view detail output
4+
# -v d
5+
dotnet pack -c Release -t:Clean,Rebuild src/libs/Mapbox.Maui/Mapbox.Maui.csproj --output $PWD/nugets

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Condition="EXISTS('Mapbox.Maui.props')" Project="Mapbox.Maui.props" />
3+
<Import Condition="EXISTS('Mapbox.Maui.targets')" Project="Mapbox.Maui.targets" />
24
<Target Name="_CleanAarOutputPath" AfterTargets="_CreateAar" BeforeTargets="_IncludeAarInNuGetPackage">
35
<Delete Files="$(_AarOutputPath)" />
46
</Target>
@@ -42,6 +44,12 @@
4244
<Compile Remove="**\**\*.iOS.cs" />
4345
</ItemGroup>
4446

47+
<PropertyGroup>
48+
<AndroidTargetSdkVersion>34</AndroidTargetSdkVersion>
49+
<AndroidSdkDirectory Condition=" '$(OS)' == 'Unix' ">$(Home)/Library/Android/sdk</AndroidSdkDirectory>
50+
<AndroidSdkDirectory Condition=" '$(OS)' != 'Unix' ">$(UserProfile)/AppData/Local/Android/sdk</AndroidSdkDirectory>
51+
</PropertyGroup>
52+
4553
<PropertyGroup>
4654
<PackageId>Mapbox.Maui</PackageId>
4755
<Title>Mapbox SDK for .NET MAUI</Title>
@@ -53,7 +61,7 @@
5361
<RepositoryUrl>https://github.com/tuyen-vuduc/mapbox-maui</RepositoryUrl>
5462
<PackageProjectUrl>https://mapbox.tuyen-vuduc.tech</PackageProjectUrl>
5563
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
56-
<PackageVersion>11.4.0-alpha02</PackageVersion>
64+
<PackageVersion>11.5.0-alpha01</PackageVersion>
5765
<PackageReadmeFile>README.md</PackageReadmeFile>
5866
<PackageLicenseFile>LICENSE</PackageLicenseFile>
5967
<PackageIcon>tv-mapbox.png</PackageIcon>
@@ -72,16 +80,17 @@
7280
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
7381
</ItemGroup>
7482
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
75-
<PackageReference Include="Com.Mapbox.Maps.Android" Version="11.4.1" />
83+
<PackageReference Include="Com.Mapbox.Maps.Android" Version="11.5.0" />
7684
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.10" />
7785
<PackageReference Include="Xamarin.AndroidX.Fragment " Version="1.7.0.2" />
7886
<PackageReference Include="Xamarin.AndroidX.Fragment.Ktx" Version="1.7.0.2" />
7987
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.9.23.3" PrivateAssets="none" />
8088
<PackageReference Include="Xamarin.Kotlin.StdLib.Common" Version="1.9.23.3" PrivateAssets="none" />
89+
<PackageReference Include="Dependencies.Gradle" Version="8.6.0.1" />
8190
</ItemGroup>
8291
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
83-
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.4.0.2" />
84-
<PackageReference Include="MapboxMaps.iOS" Version="11.4.0.1" />
92+
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.5.1" />
93+
<PackageReference Include="MapboxMaps.iOS" Version="11.5.1" />
8594
</ItemGroup>
8695
<ItemGroup>
8796
<Folder Include="Models\Styles\" />
@@ -113,4 +122,10 @@
113122
<ItemGroup>
114123
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
115124
</ItemGroup>
125+
126+
<Target
127+
Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"
128+
Name="_GradleDependencyResolverTrigger"
129+
DependsOnTargets="_GradleSync"
130+
BeforeTargets="_BuildLibraryImportsCache" />
116131
</Project>
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
<ItemGroup>
4+
<GradleRepository Include="https://api.mapbox.com/downloads/v2/releases/maven">
5+
<Repository>
6+
maven {
7+
url = uri("https://api.mapbox.com/downloads/v2/releases/maven")
8+
authentication {
9+
create&lt;BasicAuthentication&gt;("basic")
10+
}
11+
credentials {
12+
// Do not change the username below.
13+
// This should always be `mapbox` (not your username).
14+
username = "mapbox"
15+
// Use the secret token you stored in gradle.properties as the password
16+
password = providers.gradleProperty("MAPBOX_DOWNLOADS_TOKEN").get()
17+
}
18+
}
19+
</Repository>
20+
</GradleRepository>
21+
</ItemGroup>
22+
</Project>

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

+22-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ internal void InvokeMapLoaded()
104104
MapLoadedCommand.Execute(null);
105105
}
106106
}
107-
108107
public static readonly BindableProperty MapLoadedCommandProperty = BindableProperty.Create(
109108
nameof(MapLoadedCommand),
110109
typeof(ICommand),
@@ -116,4 +115,26 @@ public ICommand MapLoadedCommand
116115
get => (ICommand)GetValue(MapLoadedCommandProperty);
117116
set => SetValue(MapLoadedCommandProperty, value);
118117
}
118+
119+
public event EventHandler MapLoadingError;
120+
internal void InvokeMapLoadingError()
121+
{
122+
MapLoadingError?.Invoke(this, EventArgs.Empty);
123+
124+
if (MapLoadingErrorCommand?.CanExecute(null) == true)
125+
{
126+
MapLoadingErrorCommand.Execute(null);
127+
}
128+
}
129+
public static readonly BindableProperty MapLoadingErrorCommandProperty = BindableProperty.Create(
130+
nameof(MapLoadingErrorCommand),
131+
typeof(ICommand),
132+
typeof(MapboxView),
133+
default(ICommand)
134+
);
135+
public ICommand MapLoadingErrorCommand
136+
{
137+
get => (ICommand)GetValue(MapLoadingErrorCommandProperty);
138+
set => SetValue(MapLoadingErrorCommandProperty, value);
139+
}
119140
}

src/libs/Mapbox.Maui/Models/Annotations/ClusterOptions.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ public class ClusterOptions
2222

2323
/// Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal
2424
/// to the width of a tile, 50 by default. Value must be greater than or equal to 0.
25-
public double ClusterRadius { get; set; }
25+
public double ClusterRadius { get; set; } = 50;
2626

2727
/// Max zoom on which to cluster points if clustering is enabled. Defaults to one zoom less
2828
/// than maxzoom (so that last zoom features are not clustered). Clusters are re-evaluated at integer zoom
2929
/// levels so setting clusterMaxZoom to 14 means the clusters will be displayed until z15.
30-
public double ClusterMaxZoom { get; set; }
30+
public double ClusterMaxZoom { get; set; } = 14;
31+
32+
/// Minimum number of points necessary to form a cluster if clustering is enabled. Defaults to `2`.
33+
public double ClusterMinPoints { get; set; } = 2;
3134

3235
/// An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from
3336
/// clustered points. Has the form `{"property_name": [operator, map_expression]}`.

src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationManager.cs

+26-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
namespace MapboxMaui.Annotations;
22

3+
using Com.Mapbox.Maps.Plugins.Annotations;
4+
using System.Collections;
35
using IPlatformAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.IAnnotationManager;
46

57
public abstract partial class AnnotationManager<TAnnotationManager, TAnnotation>
68
: IAnnotationManager<TAnnotation>
7-
where TAnnotationManager: IPlatformAnnotationManager
8-
where TAnnotation: IAnnotation
9+
where TAnnotationManager : IPlatformAnnotationManager
10+
where TAnnotation : IAnnotation
911
{
1012
private readonly string id;
1113

@@ -25,7 +27,26 @@ protected AnnotationManager(
2527

2628
public event EventHandler<AnnotationsSelectedEventArgs> AnnotationsSelected;
2729

28-
public abstract void AddAnnotations(params TAnnotation[] annotations);
29-
public abstract void RemoveAllAnnotations();
30-
public abstract void RemoveAnnotations(params string[] annotationIDs);
30+
public void AddAnnotations(params TAnnotation[] annotations)
31+
{
32+
var xannotations = annotations
33+
.Select(ToPlatformAnnotationOption)
34+
.ToList();
35+
var platformAnnotations = NativeManager.Create(xannotations);
36+
for (int i = 0; i < platformAnnotations.Count; i++)
37+
{
38+
var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Annotation;
39+
annotations[i].Id = item.Id.ToString();
40+
}
41+
}
42+
public void RemoveAllAnnotations()
43+
=> NativeManager.DeleteAll();
44+
public void RemoveAnnotations(params string[] annotationIDs)
45+
{
46+
var annotations = GetNativeAnnotations(annotationIDs);
47+
NativeManager.Delete(annotations);
48+
}
49+
50+
protected abstract IAnnotationOptions ToPlatformAnnotationOption(TAnnotation annotation);
51+
protected abstract IList GetNativeAnnotations(params string[] annotationIDs);
3152
}

src/libs/Mapbox.Maui/Platforms/Android/Annotations/CircleAnnotationManager.cs

+10-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace MapboxMaui.Annotations;
22

3+
using Com.Mapbox.Maps.Plugins.Annotations;
4+
using System.Collections;
35
using PlatformCircleAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotationManager;
46

57
public partial class CircleAnnotationManager
6-
: AnnotationManager<PlatformCircleAnnotationManager, CircleAnnotation>
7-
, ICircleAnnotationManager
8+
: AnnotationManager<PlatformCircleAnnotationManager, CircleAnnotation>
9+
, ICircleAnnotationManager
810
{
911
private readonly PlatformCircleAnnotationManager nativeManager;
1012

@@ -41,28 +43,11 @@ public CircleTranslateAnchor? CircleTranslateAnchor
4143
set => nativeManager.CircleTranslateAnchor = value?.ToPlatform();
4244
}
4345

44-
public override void AddAnnotations(params CircleAnnotation[] xitems)
45-
{
46-
var items = xitems
47-
.Select(x => x.ToPlatformValue())
48-
.ToList();
49-
50-
var platformAnnotations = nativeManager.Create(items);
51-
52-
for (int i = 0; i < platformAnnotations.Count; i++)
53-
{
54-
var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotation;
55-
xitems[i].Id = item.Id.ToString();
56-
}
57-
}
58-
59-
public override void RemoveAllAnnotations()
60-
{
61-
nativeManager.Annotations.Clear();
62-
}
63-
64-
public override void RemoveAnnotations(params string[] annotationIDs)
46+
protected override IAnnotationOptions ToPlatformAnnotationOption(CircleAnnotation annotation)
47+
=> annotation.ToPlatformValue();
48+
protected override IList GetNativeAnnotations(params string[] annotationIDs)
6549
{
50+
var itemsToDelete = new List<Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotation>();
6651
foreach (var xid in annotationIDs)
6752
{
6853
var item = nativeManager
@@ -72,8 +57,9 @@ public override void RemoveAnnotations(params string[] annotationIDs)
7257

7358
if (item == null) continue;
7459

75-
nativeManager.Annotations.Remove(item);
60+
itemsToDelete.Add(item);
7661
}
62+
return itemsToDelete;
7763
}
7864
}
7965

src/libs/Mapbox.Maui/Platforms/Android/Annotations/PointAnnotationManager.cs

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace MapboxMaui.Annotations;
22

3+
using Com.Mapbox.Maps.Plugins.Annotations;
4+
using System.Collections;
35
using PlatformPointAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotationManager;
46

57
public partial class PointAnnotationManager
@@ -153,28 +155,13 @@ public TextTranslateAnchor? TextTranslateAnchor
153155
get => nativeManager.TextTranslateAnchor?.GetValue();
154156
set => nativeManager.TextTranslateAnchor = value?.ToPlatform();
155157
}
156-
public override void AddAnnotations(params PointAnnotation[] xitems)
157-
{
158-
var items = xitems
159-
.Select(x => x.ToPlatformValue())
160-
.ToList();
161-
162-
var platformAnnotations = nativeManager.Create(items);
163-
164-
for (int i = 0; i < platformAnnotations.Count; i++)
165-
{
166-
var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotation;
167-
xitems[i].Id = item.Id.ToString();
168-
}
169-
}
170158

171-
public override void RemoveAllAnnotations()
172-
{
173-
nativeManager.Annotations.Clear();
174-
}
159+
protected override IAnnotationOptions ToPlatformAnnotationOption(PointAnnotation annotation)
160+
=> annotation.ToPlatformValue();
175161

176-
public override void RemoveAnnotations(params string[] annotationIDs)
162+
protected override IList GetNativeAnnotations(params string[] annotationIDs)
177163
{
164+
var itemsToDelete = new List<Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotation>();
178165
foreach (var xid in annotationIDs)
179166
{
180167
var item = nativeManager
@@ -184,8 +171,9 @@ public override void RemoveAnnotations(params string[] annotationIDs)
184171

185172
if (item == null) continue;
186173

187-
nativeManager.Annotations.Remove(item);
174+
itemsToDelete.Add(item);
188175
}
176+
return itemsToDelete;
189177
}
190178
}
191179

src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolygonAnnotationManager.cs

+8-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace MapboxMaui.Annotations;
22

3+
using Com.Mapbox.Maps.Plugins.Annotations;
4+
using System.Collections;
35
using PlatformPolygonAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotationManager;
46

57
partial class PolygonAnnotationManager
@@ -36,28 +38,11 @@ public FillTranslateAnchor? FillTranslateAnchor
3638
: null;
3739
}
3840

39-
public override void AddAnnotations(params PolygonAnnotation[] xitems)
40-
{
41-
var items = xitems
42-
.Select(x => x.ToPlatformValue())
43-
.ToList();
44-
45-
var platformAnnotations = nativeManager.Create(items);
46-
47-
for (int i = 0; i < platformAnnotations.Count; i++)
48-
{
49-
var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotation;
50-
xitems[i].Id = item.Id.ToString();
51-
}
52-
}
53-
54-
public override void RemoveAllAnnotations()
55-
{
56-
nativeManager.Annotations.Clear();
57-
}
58-
59-
public override void RemoveAnnotations(params string[] annotationIDs)
41+
protected override IAnnotationOptions ToPlatformAnnotationOption(PolygonAnnotation annotation)
42+
=> annotation.ToPlatformValue();
43+
protected override IList GetNativeAnnotations(params string[] annotationIDs)
6044
{
45+
var itemsToDelete = new List<Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotation>();
6146
foreach (var id in annotationIDs)
6247
{
6348
var item = nativeManager
@@ -67,7 +52,8 @@ public override void RemoveAnnotations(params string[] annotationIDs)
6752

6853
if (item == null) continue;
6954

70-
nativeManager.Annotations.Remove(item);
55+
itemsToDelete.Add(item);
7156
}
57+
return itemsToDelete;
7258
}
7359
}

0 commit comments

Comments
 (0)