Skip to content

Commit

Permalink
feat: v11.3.0 -alpha03 (#14)
Browse files Browse the repository at this point in the history
* WIP

* - new sample

* - correct package version

(cherry picked from commit 7002f7b68fd805250a98b39dc001b70fe983086d)

* - hide build errors

(cherry picked from commit 9746886adb1a4f6aa6d2fda209434d214a3ae7cb)

* - hide build errors

* - Checking iOS [WIP]

* - set access token for iOS

* - remove unnecessary code

* - add groupindex and item index

* - align built-in styles to v11.1.0 Android SDK

* - upgrade nuget version

* - Fix many TODOs

* - MapboxMapsObjc v11.1.0

* - use Mapbox SDK v11 (many examples not working)

* - Set lib version

* - correct version in readme

* Extend GeometryExtension on Android to support converting Point to MapTappedPosition

* MapboxFragment - Implement long clicked listener

* Add new event and command for shared MapboxView that handles long click

* Android MapboxViewHandler - handle long click event from fragment

* iOS MapboxViewHandler - support long press

* Android - unsubscribe long press in handler

* iOS - Check long press state and make sure event is triggered only 1 time, when it begins

* iOS - Add extension which helps with creating MapTappedPosition

* Android - Fix issue where MapTappedPosition doesn't contain actual screen coordinates

* Android - for screen coordinates adjust pixels to dp

* - use .NET8
- use latest Mapbox SDK 11.3.x

* - use latesting Android SDK binding

* - correct nuget.config

* Support geojson string ios (#12)

* 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

* feat: Sample AnimatePointAnnotation (not done) (#15)

* - only pack the MAUI lib

* - Change to IPosition instead of GeoJSON.Point for MapTappedLocation
- Change MapTappedPosition to a record
- Add CoordinateBounds

* - Add empty example AnimatePointAnnotation

* - fix issue of converting MapboxGeoJSON Point to GeoJSON.NET.Position

* bumb new version

---------

Co-authored-by: Andrei Dinca <>
Co-authored-by: DincaAndrei <[email protected]>
  • Loading branch information
tuyen-vuduc and DincaAndrei2410 authored Jun 26, 2024
1 parent 2eacf25 commit fc1816b
Show file tree
Hide file tree
Showing 104 changed files with 1,961 additions and 2,351 deletions.
15 changes: 11 additions & 4 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {}
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
39 changes: 33 additions & 6 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ jobs:
if: ${{ inputs.SHOULD_RUN }}
steps:
- uses: actions/checkout@v3
- name: Set default Xamarin SDK versions
run: |
$VM_ASSETS/select-xamarin-sdk-v2.sh --mono=6.12 --android=13.0

- name: Set .netrc
run: |
echo $NETRC >> ~/.netrc
Expand All @@ -26,18 +23,48 @@ jobs:
env:
NETRC : ${{secrets.NETRC}}

- name: Setup .NET Core SDK 7.0.306
- name: Setup .NET Core SDK 8.0
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.306'
dotnet-version: '8.0'

- name: Install ios workload
run: |
dotnet workload install ios android maui maui-ios maui-android
- name: Setup Java 17
uses: actions/setup-java@v3
with:
distribution: 'microsoft'
java-version: '17'

- name: Xcode Select Version
uses: mobiledevops/xcode-select-version-action@v1
with:
xcode-select-version: 15.1

- name: Set MAPBOX_DOWNLOADS_TOKEN
if: contains(${{ inputs.LIB_ARTIFACT }}, 'com.mapbox.maps')
run: |
echo "MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN" >> ~/.gradle/gradle.properties
cat ~/.gradle/gradle.properties
shell: bash
env:
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}

- name: Create MauiProgram.dev.cs
run: |
cp src/qs/MapboxMauiQs/MauiProgram.dev.cs.example src/qs/MapboxMauiQs/MauiProgram.dev.cs
# - name: Create MapboxMauiQs.props
# run: |
# echo "${{ secrets.PROJECT_PROPS }}" > src/qs/MapboxMauiQs/MapboxMauiQs.props

- name: Build
run: |
sh build.sh
env:
MAPBOX_DOWNLOADS_TOKEN : ${{ secrets.MAPBOX_DOWNLOADS_TOKEN }}

- name: Publish NuGet and symbols
id: nuget-push
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A dedicated library and starting sample for integrating Mapbox into your MAUI ap
# Installation

```
Install-Package Mapbox.Maui --version 10.11.1.1
Install-Package Mapbox.Maui --version 11.1.0-alpha01
```

## Integrate into your project
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
dotnet nuget locals -c all
dotnet pack -c Release -t:Clean,Rebuild src/libs/Mapbox.Maui/Mapbox.Maui.csproj --output $PWD/nugets

# Build to trigger gradle process
dotnet build -t:Clean,Rebuild src/qs/MapboxMauiQs/MapboxMauiQs.csproj \
-property:MAPBOX_DOWNLOADS_TOKEN=$MAPBOX_DOWNLOADS_TOKEN

dotnet pack -c Release -t:Clean,Rebuild src/libs/Mapbox.Maui/Mapbox.Maui.csproj \
--output $PWD/nugets
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.306",
"version": "8.0.100",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion nuget.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="Mapbox-Local" value="nugets" />
<add key="Local" value="nugets" />
</packageSources>
</configuration>
10 changes: 8 additions & 2 deletions src/libs/Mapbox.Maui/IMapboxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public partial interface IMapboxView : IView
{
CameraOptions CameraOptions { get; set; }
MapboxStyle MapboxStyle { get; set; }
Point? MapCenter { get; set; }
IPosition MapCenter { get; set; }
float? MapZoom { get; set; }

OrnamentVisibility ScaleBarVisibility { get; set; }
Expand Down Expand Up @@ -58,7 +58,13 @@ public interface IAnnotationController

public interface IMapFeatureQueryable
{
Task<IEnumerable<QueriedFeature>> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options);
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options);
}

public interface IMapboxController
{
IPosition GetMapPosition(ScreenPosition position);
CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions);
}

public class MapTappedEventArgs : EventArgs
Expand Down
45 changes: 25 additions & 20 deletions src/libs/Mapbox.Maui/Mapbox.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Target Name="_CleanAarOutputPath" AfterTargets="_CreateAar" BeforeTargets="_IncludeAarInNuGetPackage">
<Delete Files="$(_AarOutputPath)" />
</Target>

<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net7.0-android;net7.0-ios;</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios;</TargetFrameworks>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.4</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">26.0</SupportedOSPlatformVersion>
<RootNamespace>MapboxMaui</RootNamespace>
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
</PropertyGroup>
Expand All @@ -24,23 +27,20 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-android')) != true">
<ItemGroup Condition=" $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'android' ">
<Compile Remove="**\**\*.Android.cs" />
</ItemGroup>

<!-- Both iOS and Mac Catalyst -->
<ItemGroup Condition="$(TargetFramework.Contains('-ios')) != true AND $(TargetFramework.Contains('-maccatalyst')) != true">
<ItemGroup Condition=" $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios' AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst' ">
<Compile Remove="**\**\*.MaciOS.cs" />
<None Include="**\**\*.MaciOS.cs" Exclude="$(DefaultItemExcludes);$(DefaultExcludesInProjectFolder)" />
</ItemGroup>

<!-- iOS -->
<ItemGroup Condition="$(TargetFramework.Contains('-ios')) != true">
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios'">
<Compile Remove="**\**\*.iOS.cs" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.Contains('-ios')) == true">
<Compile Include="**\**\*.iOS.cs" />
</ItemGroup>

<PropertyGroup>
<PackageId>Mapbox.Maui</PackageId>
Expand All @@ -53,32 +53,34 @@
<RepositoryUrl>https://github.com/tuyen-vuduc/mapbox-maui</RepositoryUrl>
<PackageProjectUrl>https://mapbox.tuyen-vuduc.tech</PackageProjectUrl>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageVersion>10.11.1.1</PackageVersion>
<PackageVersion>11.3.0-alpha03</PackageVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIcon>tv-mapbox.png</PackageIcon>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<None Include="../../../assets/tv-mapbox.png" Pack="True" PackagePath="tv-mapbox.png" />
<None Include="../../../LICENSE" Pack="True" PackagePath="" />
<None Include="../../../README.md" Pack="True" PackagePath="README.md" />

<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Xamarin.Build.Download" Version="0.11.4" />
<PackageReference Include="GeoJSON.Text" Version="1.0.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<PackageReference Include="Com.Mapbox.Maps.Android" Version="10.11.1" />
<PackageReference Include="Xamarin.Kotlin.StdLib.Jdk8" Version="1.9.0.1" />
<PackageReference Include="Square.OkHttp3" Version="4.10.0.1" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.9.0.1" />
<PackageReference Include="Xamarin.AndroidX.Annotation" Version="1.6.0.4" />
<PackageReference Include="Com.Mapbox.Maps.Android" Version="11.3.1.7" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.8" />
<PackageReference Include="Xamarin.AndroidX.Fragment.Ktx" Version="1.6.2.3" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.9.23.1" PrivateAssets="none" />
<PackageReference Include="Xamarin.Kotlin.StdLib.Common" Version="1.9.23.1" PrivateAssets="none" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<PackageReference Include="MapboxMapsObjC.iOS" Version="10.11.1.1" />
<PackageReference Include="MapboxMobileEvents.iOS" Version="1.0.10.1" />
<PackageReference Include="MapboxMapsObjC.iOS" Version="11.3.0.3" />
<PackageReference Include="MapboxMaps.iOS" Version="11.3.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\Styles\" />
Expand All @@ -102,4 +104,7 @@
</Properties>
</MonoDevelop>
</ProjectExtensions>
<ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.40" />
</ItemGroup>
</Project>
32 changes: 23 additions & 9 deletions src/libs/Mapbox.Maui/MapboxView.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
partial class MapboxView
{
public event EventHandler<MapTappedEventArgs> MapTapped;
public event EventHandler<MapTappedEventArgs> MapLongTapped;
internal void InvokeMapTapped(MapTappedPosition point)
{
MapTapped?.Invoke(this, new MapTappedEventArgs(point));
Expand All @@ -14,6 +15,27 @@ internal void InvokeMapTapped(MapTappedPosition point)
Command.Execute(point);
}
}

internal void InvokeMapLongTapped(MapTappedPosition position)
{
MapLongTapped?.Invoke(this, new MapTappedEventArgs(position));

if (LongTapCommand?.CanExecute(position) == true)
{
LongTapCommand.Execute(position);
}
}

public static readonly BindableProperty LongTapCommandProperty = BindableProperty.Create(
nameof(LongTapCommand),
typeof(ICommand),
typeof(MapboxView)
);
public ICommand LongTapCommand
{
get => (ICommand)GetValue(CommandProperty);
set => SetValue(CommandProperty, value);
}

public static readonly BindableProperty CommandProperty = BindableProperty.Create(
nameof(Command),
Expand Down Expand Up @@ -94,12 +116,4 @@ public ICommand MapLoadedCommand
get => (ICommand)GetValue(MapLoadedCommandProperty);
set => SetValue(MapLoadedCommandProperty, value);
}
}

public class MapTappedPosition
{
public Point ScreenPosition { get; set; }

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

}
13 changes: 7 additions & 6 deletions src/libs/Mapbox.Maui/MapboxView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ public CameraOptions CameraOptions

public static readonly BindableProperty MapCenterProperty = BindableProperty.Create(
nameof(MapCenter),
typeof(Point?),
typeof(IPosition),
typeof(MapboxView),
default(Point?)
default(IPosition)
);
public Point? MapCenter
public IPosition MapCenter
{
get => CameraOptions.Center;
set => CameraOptions = CameraOptions with
Expand All @@ -149,11 +149,11 @@ public Thickness? MapPadding

public static readonly BindableProperty MapAnchorProperty = BindableProperty.Create(
nameof(MapAnchor),
typeof(Point?),
typeof(ScreenPosition?),
typeof(MapboxView),
default(Point?)
default(ScreenPosition?)
);
public Point? MapAnchor
public ScreenPosition? MapAnchor
{
get => CameraOptions.Anchor;
set => CameraOptions = CameraOptions with
Expand Down Expand Up @@ -221,4 +221,5 @@ public MapboxStyle MapboxStyle

public IAnnotationController AnnotationController { get; internal set; }
public IMapFeatureQueryable QueryManager { get; internal set; }
public IMapboxController MapboxController { get; internal set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public interface IPointAnnotationManager : IAnnotationManager<PointAnnotation>
double? IconPadding { get; set; }
IconPitchAlignment? IconPitchAlignment { get; set; }
IconRotationAlignment? IconRotationAlignment { get; set; }
IconTextFit? IconTextFit { get; set; }
double[] IconTextFitPadding { get; set; }
bool? SymbolAvoidEdges { get; set; }
SymbolPlacement? SymbolPlacement { get; set; }
double? SymbolSpacing { get; set; }
Expand All @@ -30,7 +28,6 @@ public interface IPointAnnotationManager : IAnnotationManager<PointAnnotation>
IconTranslateAnchor? IconTranslateAnchor { get; set; }
double[] TextTranslate { get; set; }
TextTranslateAnchor? TextTranslateAnchor { get; set; }
double? TextLineHeight { get; set; }
}

public partial class PointAnnotationManager
Expand Down
5 changes: 1 addition & 4 deletions src/libs/Mapbox.Maui/Models/BaseKVContainer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;

namespace MapboxMaui;
namespace MapboxMaui;

public abstract class BaseKVContainer : INotifyCollectionChanged
{
Expand Down
4 changes: 2 additions & 2 deletions src/libs/Mapbox.Maui/Models/CameraOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public record struct CameraOptions
{
public Point? Center { get; set; }
public IPosition Center { get; set; }
public Thickness? Padding { get; set; }
public Point? Anchor { get; set; }
public ScreenPosition? Anchor { get; set; }
public float? Zoom { get; set; }
public float? Bearing { get; set; }
public float? Pitch { get; set; }
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Mapbox.Maui/Models/CoordinateBounds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace MapboxMaui;

public record CoordinateBounds (
IPosition Southwest,
IPosition Northeast,
bool InfiniteBounds = false);
Loading

0 comments on commit fc1816b

Please sign in to comment.