diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 517f9b3..da200cd 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -1,5 +1,12 @@ -{ - "version": 1, - "isRoot": true, - "tools": {} +{ + "version": 1, + "isRoot": true, + "tools": { + "cake.tool": { + "version": "4.0.0", + "commands": [ + "dotnet-cake" + ] + } + } } \ No newline at end of file diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index a0deedf..0767b2c 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -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 @@ -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 diff --git a/README.md b/README.md index c4e5129..7eb4fbe 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/build.sh b/build.sh index 95427a9..4a40606 100644 --- a/build.sh +++ b/build.sh @@ -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 \ No newline at end of file + +# 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 \ No newline at end of file diff --git a/global.json b/global.json index 91e099f..7d3b56c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.306", + "version": "8.0.100", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/nuget.config b/nuget.config index 8a53270..ba7edaf 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/IMapboxView.cs b/src/libs/Mapbox.Maui/IMapboxView.cs index 55e07d8..6c1a68e 100644 --- a/src/libs/Mapbox.Maui/IMapboxView.cs +++ b/src/libs/Mapbox.Maui/IMapboxView.cs @@ -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; } @@ -58,7 +58,13 @@ public interface IAnnotationController public interface IMapFeatureQueryable { - Task> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options); + Task> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options); +} + +public interface IMapboxController +{ + IPosition GetMapPosition(ScreenPosition position); + CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions); } public class MapTappedEventArgs : EventArgs diff --git a/src/libs/Mapbox.Maui/Mapbox.Maui.csproj b/src/libs/Mapbox.Maui/Mapbox.Maui.csproj index 3a52821..77a0955 100644 --- a/src/libs/Mapbox.Maui/Mapbox.Maui.csproj +++ b/src/libs/Mapbox.Maui/Mapbox.Maui.csproj @@ -1,13 +1,16 @@ - + + + + - net6.0-android;net6.0-ios;net7.0-android;net7.0-ios; + net8.0-android;net8.0-ios; true true enable 15.4 - 21.0 + 26.0 MapboxMaui true @@ -24,23 +27,20 @@ latestmajor - + - + - + - - - Mapbox.Maui @@ -53,32 +53,34 @@ https://github.com/tuyen-vuduc/mapbox-maui https://mapbox.tuyen-vuduc.tech false - 10.11.1.1 + 11.3.0-alpha03 README.md LICENSE tv-mapbox.png + + false + - + + - - - - - - + + + + + - - - + + @@ -102,4 +104,7 @@ + + + diff --git a/src/libs/Mapbox.Maui/MapboxView.Events.cs b/src/libs/Mapbox.Maui/MapboxView.Events.cs index f1fde18..5154c16 100644 --- a/src/libs/Mapbox.Maui/MapboxView.Events.cs +++ b/src/libs/Mapbox.Maui/MapboxView.Events.cs @@ -5,6 +5,7 @@ partial class MapboxView { public event EventHandler MapTapped; + public event EventHandler MapLongTapped; internal void InvokeMapTapped(MapTappedPosition point) { MapTapped?.Invoke(this, new MapTappedEventArgs(point)); @@ -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), @@ -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; } -} - +} \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/MapboxView.cs b/src/libs/Mapbox.Maui/MapboxView.cs index edbc232..7d734b8 100644 --- a/src/libs/Mapbox.Maui/MapboxView.cs +++ b/src/libs/Mapbox.Maui/MapboxView.cs @@ -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 @@ -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 @@ -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; } } \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Models/Annotations/IPointAnnotationManager.cs b/src/libs/Mapbox.Maui/Models/Annotations/IPointAnnotationManager.cs index d7aa1e9..2890a5c 100644 --- a/src/libs/Mapbox.Maui/Models/Annotations/IPointAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Models/Annotations/IPointAnnotationManager.cs @@ -9,8 +9,6 @@ public interface IPointAnnotationManager : IAnnotationManager 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; } @@ -30,7 +28,6 @@ public interface IPointAnnotationManager : IAnnotationManager IconTranslateAnchor? IconTranslateAnchor { get; set; } double[] TextTranslate { get; set; } TextTranslateAnchor? TextTranslateAnchor { get; set; } - double? TextLineHeight { get; set; } } public partial class PointAnnotationManager diff --git a/src/libs/Mapbox.Maui/Models/BaseKVContainer.cs b/src/libs/Mapbox.Maui/Models/BaseKVContainer.cs index 2a6541f..9bc05a5 100644 --- a/src/libs/Mapbox.Maui/Models/BaseKVContainer.cs +++ b/src/libs/Mapbox.Maui/Models/BaseKVContainer.cs @@ -1,7 +1,4 @@ -using System.Collections.ObjectModel; -using System.Collections.Specialized; - -namespace MapboxMaui; +namespace MapboxMaui; public abstract class BaseKVContainer : INotifyCollectionChanged { diff --git a/src/libs/Mapbox.Maui/Models/CameraOptions.cs b/src/libs/Mapbox.Maui/Models/CameraOptions.cs index 435aced..c4e25c7 100644 --- a/src/libs/Mapbox.Maui/Models/CameraOptions.cs +++ b/src/libs/Mapbox.Maui/Models/CameraOptions.cs @@ -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; } diff --git a/src/libs/Mapbox.Maui/Models/CoordinateBounds.cs b/src/libs/Mapbox.Maui/Models/CoordinateBounds.cs new file mode 100644 index 0000000..19ab35c --- /dev/null +++ b/src/libs/Mapbox.Maui/Models/CoordinateBounds.cs @@ -0,0 +1,6 @@ +namespace MapboxMaui; + +public record CoordinateBounds ( + IPosition Southwest, + IPosition Northeast, + bool InfiniteBounds = false); \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Models/Expressions/AllExpressions.cs b/src/libs/Mapbox.Maui/Models/Expressions/AllExpressions.cs index 7c9aa4a..c6f6b80 100644 --- a/src/libs/Mapbox.Maui/Models/Expressions/AllExpressions.cs +++ b/src/libs/Mapbox.Maui/Models/Expressions/AllExpressions.cs @@ -302,200 +302,192 @@ partial class ExpressionOperatorExtensions { public static MapboxMapsObjC.TMBExpressionOperator ToPlatform(this ExpressionOperator value) { - return value.Value switch - { - "-" => MapboxMapsObjC.TMBExpressionOperator.Subtract, - "!" => MapboxMapsObjC.TMBExpressionOperator.Not, - "!=" => MapboxMapsObjC.TMBExpressionOperator.Neq, - "*" => MapboxMapsObjC.TMBExpressionOperator.Product, - "/" => MapboxMapsObjC.TMBExpressionOperator.Division, - "%" => MapboxMapsObjC.TMBExpressionOperator.Mod, - "^" => MapboxMapsObjC.TMBExpressionOperator.Pow, - "+" => MapboxMapsObjC.TMBExpressionOperator.Sum, - "<" => MapboxMapsObjC.TMBExpressionOperator.Lt, - "<=" => MapboxMapsObjC.TMBExpressionOperator.Lte, - "==" => MapboxMapsObjC.TMBExpressionOperator.Eq, - ">" => MapboxMapsObjC.TMBExpressionOperator.Gt, - ">=" => MapboxMapsObjC.TMBExpressionOperator.Gte, - "abs" => MapboxMapsObjC.TMBExpressionOperator.Abs, - "accumulated" => MapboxMapsObjC.TMBExpressionOperator.Accumulated, - "acos" => MapboxMapsObjC.TMBExpressionOperator.Acos, - "all" => MapboxMapsObjC.TMBExpressionOperator.All, - "any" => MapboxMapsObjC.TMBExpressionOperator.Any, - "array" => MapboxMapsObjC.TMBExpressionOperator.Array, - "asin" => MapboxMapsObjC.TMBExpressionOperator.Asin, - "at" => MapboxMapsObjC.TMBExpressionOperator.At, - "atan" => MapboxMapsObjC.TMBExpressionOperator.Atan, - "boolean" => MapboxMapsObjC.TMBExpressionOperator.Boolean, - "case" => MapboxMapsObjC.TMBExpressionOperator.SwitchCase, - "ceil" => MapboxMapsObjC.TMBExpressionOperator.Ceil, - "coalesce" => MapboxMapsObjC.TMBExpressionOperator.Coalesce, - "collator" => MapboxMapsObjC.TMBExpressionOperator.Collator, - "concat" => MapboxMapsObjC.TMBExpressionOperator.Concat, - "cos" => MapboxMapsObjC.TMBExpressionOperator.Cos, - "distance" => MapboxMapsObjC.TMBExpressionOperator.Distance, - "distance-from-center" => MapboxMapsObjC.TMBExpressionOperator.DistanceFromCenter, - "downcase" => MapboxMapsObjC.TMBExpressionOperator.Downcase, - "e" => MapboxMapsObjC.TMBExpressionOperator.E, - "feature-state" => MapboxMapsObjC.TMBExpressionOperator.FeatureState, - "floor" => MapboxMapsObjC.TMBExpressionOperator.Floor, - "format" => MapboxMapsObjC.TMBExpressionOperator.Format, - "geometry-type" => MapboxMapsObjC.TMBExpressionOperator.GeometryType, - "get" => MapboxMapsObjC.TMBExpressionOperator.Get, - "has" => MapboxMapsObjC.TMBExpressionOperator.Has, - "heatmap-density" => MapboxMapsObjC.TMBExpressionOperator.HeatmapDensity, - "id" => MapboxMapsObjC.TMBExpressionOperator.Id, - "image" => MapboxMapsObjC.TMBExpressionOperator.Image, - "in" => MapboxMapsObjC.TMBExpressionOperator.InExpression, - "index-of" => MapboxMapsObjC.TMBExpressionOperator.IndexOf, - "interpolate" => MapboxMapsObjC.TMBExpressionOperator.Interpolate, - "is-supported-script" => MapboxMapsObjC.TMBExpressionOperator.IsSupportedScript, - "length" => MapboxMapsObjC.TMBExpressionOperator.Length, - "let" => MapboxMapsObjC.TMBExpressionOperator.LetExpression, - "line-progress" => MapboxMapsObjC.TMBExpressionOperator.LineProgress, - "literal" => MapboxMapsObjC.TMBExpressionOperator.Literal, - "ln" => MapboxMapsObjC.TMBExpressionOperator.Ln, - "ln2" => MapboxMapsObjC.TMBExpressionOperator.Ln2, - "log10" => MapboxMapsObjC.TMBExpressionOperator.Log10, - "log2" => MapboxMapsObjC.TMBExpressionOperator.Log2, - "match" => MapboxMapsObjC.TMBExpressionOperator.Match, - "max" => MapboxMapsObjC.TMBExpressionOperator.Max, - "min" => MapboxMapsObjC.TMBExpressionOperator.Min, - "number" => MapboxMapsObjC.TMBExpressionOperator.Number, - "number-format" => MapboxMapsObjC.TMBExpressionOperator.NumberFormat, - "object" => MapboxMapsObjC.TMBExpressionOperator.ObjectExpression, - "pi" => MapboxMapsObjC.TMBExpressionOperator.Pi, - "pitch" => MapboxMapsObjC.TMBExpressionOperator.Pitch, - "properties" => MapboxMapsObjC.TMBExpressionOperator.Properties, - "resolved-locale" => MapboxMapsObjC.TMBExpressionOperator.ResolvedLocale, - "rgb" => MapboxMapsObjC.TMBExpressionOperator.Rgb, - "rgba" => MapboxMapsObjC.TMBExpressionOperator.Rgba, - "round" => MapboxMapsObjC.TMBExpressionOperator.Round, - "sin" => MapboxMapsObjC.TMBExpressionOperator.Sin, - "sky-radial-progress" => MapboxMapsObjC.TMBExpressionOperator.SkyRadialProgress, - "slice" => MapboxMapsObjC.TMBExpressionOperator.Slice, - "sqrt" => MapboxMapsObjC.TMBExpressionOperator.Sqrt, - "step" => MapboxMapsObjC.TMBExpressionOperator.Step, - "string" => MapboxMapsObjC.TMBExpressionOperator.String, - "tan" => MapboxMapsObjC.TMBExpressionOperator.Tan, - "to-boolean" => MapboxMapsObjC.TMBExpressionOperator.ToBoolean, - "to-color" => MapboxMapsObjC.TMBExpressionOperator.ToColor, - "to-number" => MapboxMapsObjC.TMBExpressionOperator.ToNumber, - "to-rgba" => MapboxMapsObjC.TMBExpressionOperator.ToRgba, - "to-string" => MapboxMapsObjC.TMBExpressionOperator.ToString, - "typeof" => MapboxMapsObjC.TMBExpressionOperator.TypeofExpression, - "upcase" => MapboxMapsObjC.TMBExpressionOperator.Upcase, - "var" => MapboxMapsObjC.TMBExpressionOperator.VarExpression, - "within" => MapboxMapsObjC.TMBExpressionOperator.Within, - "zoom" => MapboxMapsObjC.TMBExpressionOperator.Zoom, - "linear" => MapboxMapsObjC.TMBExpressionOperator.Linear, - "exponential" => MapboxMapsObjC.TMBExpressionOperator.Exponential, - "cubic-bezier" => MapboxMapsObjC.TMBExpressionOperator.CubicBezier - }; + return new MapboxMapsObjC.TMBExpressionOperator(value.Value); + //return value.Value switch + //{ + // "-" => MapboxMapsObjC.TMBExpressionOperator.Subtract, + // "!" => MapboxMapsObjC.TMBExpressionOperator.Not_, + // "!=" => MapboxMapsObjC.TMBExpressionOperator.Neq, + // "*" => MapboxMapsObjC.TMBExpressionOperator.Product, + // "/" => MapboxMapsObjC.TMBExpressionOperator.Division, + // "%" => MapboxMapsObjC.TMBExpressionOperator.Mod, + // "^" => MapboxMapsObjC.TMBExpressionOperator.Pow, + // "+" => MapboxMapsObjC.TMBExpressionOperator.Sum, + // "<" => MapboxMapsObjC.TMBExpressionOperator.Lt, + // "<=" => MapboxMapsObjC.TMBExpressionOperator.Lte, + // "==" => MapboxMapsObjC.TMBExpressionOperator.Eq, + // ">" => MapboxMapsObjC.TMBExpressionOperator.Gt, + // ">=" => MapboxMapsObjC.TMBExpressionOperator.Gte, + // "abs" => MapboxMapsObjC.TMBExpressionOperator.Abs, + // "accumulated" => MapboxMapsObjC.TMBExpressionOperator.Accumulated, + // "acos" => MapboxMapsObjC.TMBExpressionOperator.Acos, + // "all" => MapboxMapsObjC.TMBExpressionOperator.All, + // "any" => MapboxMapsObjC.TMBExpressionOperator.Any, + // "array" => MapboxMapsObjC.TMBExpressionOperator.Array, + // "asin" => MapboxMapsObjC.TMBExpressionOperator.Asin, + // "at" => MapboxMapsObjC.TMBExpressionOperator.At, + // "atan" => MapboxMapsObjC.TMBExpressionOperator.Atan, + // "boolean" => MapboxMapsObjC.TMBExpressionOperator.Boolean, + // "case" => MapboxMapsObjC.TMBExpressionOperator.SwitchCase, + // "ceil" => MapboxMapsObjC.TMBExpressionOperator.Ceil, + // "coalesce" => MapboxMapsObjC.TMBExpressionOperator.Coalesce, + // "collator" => MapboxMapsObjC.TMBExpressionOperator.Collator, + // "concat" => MapboxMapsObjC.TMBExpressionOperator.Concat, + // "cos" => MapboxMapsObjC.TMBExpressionOperator.Cos, + // "distance" => MapboxMapsObjC.TMBExpressionOperator.Distance, + // "distance-from-center" => MapboxMapsObjC.TMBExpressionOperator.DistanceFromCenter, + // "downcase" => MapboxMapsObjC.TMBExpressionOperator.Downcase, + // "e" => MapboxMapsObjC.TMBExpressionOperator.E, + // "feature-state" => MapboxMapsObjC.TMBExpressionOperator.FeatureState, + // "floor" => MapboxMapsObjC.TMBExpressionOperator.Floor, + // "format" => MapboxMapsObjC.TMBExpressionOperator.Format, + // "geometry-type" => MapboxMapsObjC.TMBExpressionOperator.GeometryType, + // "get" => MapboxMapsObjC.TMBExpressionOperator.Get, + // "has" => MapboxMapsObjC.TMBExpressionOperator.Has, + // "heatmap-density" => MapboxMapsObjC.TMBExpressionOperator.HeatmapDensity, + // "id" => MapboxMapsObjC.TMBExpressionOperator.Id, + // "image" => MapboxMapsObjC.TMBExpressionOperator.Image, + // "in" => MapboxMapsObjC.TMBExpressionOperator.InExpression, + // "index-of" => MapboxMapsObjC.TMBExpressionOperator.IndexOf, + // "interpolate" => MapboxMapsObjC.TMBExpressionOperator.Interpolate, + // "is-supported-script" => MapboxMapsObjC.TMBExpressionOperator.IsSupportedScript, + // "length" => MapboxMapsObjC.TMBExpressionOperator.Length, + // "let" => MapboxMapsObjC.TMBExpressionOperator.LetExpression, + // "line-progress" => MapboxMapsObjC.TMBExpressionOperator.LineProgress, + // "literal" => MapboxMapsObjC.TMBExpressionOperator.Literal, + // "ln" => MapboxMapsObjC.TMBExpressionOperator.Ln, + // "ln2" => MapboxMapsObjC.TMBExpressionOperator.Ln2, + // "log10" => MapboxMapsObjC.TMBExpressionOperator.Log10, + // "log2" => MapboxMapsObjC.TMBExpressionOperator.Log2, + // "match" => MapboxMapsObjC.TMBExpressionOperator.Match, + // "max" => MapboxMapsObjC.TMBExpressionOperator.Max, + // "min" => MapboxMapsObjC.TMBExpressionOperator.Min, + // "number" => MapboxMapsObjC.TMBExpressionOperator.Number, + // "number-format" => MapboxMapsObjC.TMBExpressionOperator.NumberFormat, + // "object" => MapboxMapsObjC.TMBExpressionOperator.ObjectExpression, + // "pi" => MapboxMapsObjC.TMBExpressionOperator.Pi, + // "pitch" => MapboxMapsObjC.TMBExpressionOperator.Pitch, + // "properties" => MapboxMapsObjC.TMBExpressionOperator.Properties, + // "resolved-locale" => MapboxMapsObjC.TMBExpressionOperator.ResolvedLocale, + // "rgb" => MapboxMapsObjC.TMBExpressionOperator.Rgb, + // "rgba" => MapboxMapsObjC.TMBExpressionOperator.Rgba, + // "round" => MapboxMapsObjC.TMBExpressionOperator.Round, + // "sin" => MapboxMapsObjC.TMBExpressionOperator.Sin, + // "sky-radial-progress" => MapboxMapsObjC.TMBExpressionOperator.SkyRadialProgress, + // "slice" => MapboxMapsObjC.TMBExpressionOperator.Slice, + // "sqrt" => MapboxMapsObjC.TMBExpressionOperator.Sqrt, + // "step" => MapboxMapsObjC.TMBExpressionOperator.Step, + // "string" => MapboxMapsObjC.TMBExpressionOperator.String, + // "tan" => MapboxMapsObjC.TMBExpressionOperator.Tan, + // "to-boolean" => MapboxMapsObjC.TMBExpressionOperator.ToBoolean, + // "to-color" => MapboxMapsObjC.TMBExpressionOperator.ToColor, + // "to-number" => MapboxMapsObjC.TMBExpressionOperator.ToNumber, + // "to-rgba" => MapboxMapsObjC.TMBExpressionOperator.ToRgba, + // "to-string" => MapboxMapsObjC.TMBExpressionOperator.ToString, + // "typeof" => MapboxMapsObjC.TMBExpressionOperator.TypeofExpression, + // "upcase" => MapboxMapsObjC.TMBExpressionOperator.Upcase, + // "var" => MapboxMapsObjC.TMBExpressionOperator.VarExpression, + // "within" => MapboxMapsObjC.TMBExpressionOperator.Within, + // "zoom" => MapboxMapsObjC.TMBExpressionOperator.Zoom, + // "linear" => MapboxMapsObjC.TMBExpressionOperator.Linear, + // "exponential" => MapboxMapsObjC.TMBExpressionOperator.Exponential, + // "cubic-bezier" => MapboxMapsObjC.TMBExpressionOperator.CubicBezier + //}; } public static ExpressionOperator ToPlatform(this MapboxMapsObjC.TMBExpressionOperator value) { - return value switch - { - MapboxMapsObjC.TMBExpressionOperator.Subtract => "-", - MapboxMapsObjC.TMBExpressionOperator.Not => "!", - MapboxMapsObjC.TMBExpressionOperator.Neq => "!=", - MapboxMapsObjC.TMBExpressionOperator.Product => "*", - MapboxMapsObjC.TMBExpressionOperator.Division => "/", - MapboxMapsObjC.TMBExpressionOperator.Mod => "%", - MapboxMapsObjC.TMBExpressionOperator.Pow => "^", - MapboxMapsObjC.TMBExpressionOperator.Sum => "+", - MapboxMapsObjC.TMBExpressionOperator.Lt => "<", - MapboxMapsObjC.TMBExpressionOperator.Lte => "<=", - MapboxMapsObjC.TMBExpressionOperator.Eq => "==", - MapboxMapsObjC.TMBExpressionOperator.Gt => ">", - MapboxMapsObjC.TMBExpressionOperator.Gte => ">=", - MapboxMapsObjC.TMBExpressionOperator.Abs => "abs", - MapboxMapsObjC.TMBExpressionOperator.Accumulated => "accumulated", - MapboxMapsObjC.TMBExpressionOperator.Acos => "acos", - MapboxMapsObjC.TMBExpressionOperator.All => "all", - MapboxMapsObjC.TMBExpressionOperator.Any => "any", - MapboxMapsObjC.TMBExpressionOperator.Array => "array", - MapboxMapsObjC.TMBExpressionOperator.Asin => "asin", - MapboxMapsObjC.TMBExpressionOperator.At => "at", - MapboxMapsObjC.TMBExpressionOperator.Atan => "atan", - MapboxMapsObjC.TMBExpressionOperator.Boolean => "boolean", - MapboxMapsObjC.TMBExpressionOperator.SwitchCase => "case", - MapboxMapsObjC.TMBExpressionOperator.Ceil => "ceil", - MapboxMapsObjC.TMBExpressionOperator.Coalesce => "coalesce", - MapboxMapsObjC.TMBExpressionOperator.Collator => "collator", - MapboxMapsObjC.TMBExpressionOperator.Concat => "concat", - MapboxMapsObjC.TMBExpressionOperator.Cos => "cos", - MapboxMapsObjC.TMBExpressionOperator.Distance => "distance", - MapboxMapsObjC.TMBExpressionOperator.DistanceFromCenter => "distance-from-center", - MapboxMapsObjC.TMBExpressionOperator.Downcase => "downcase", - MapboxMapsObjC.TMBExpressionOperator.E => "e", - MapboxMapsObjC.TMBExpressionOperator.FeatureState => "feature-state", - MapboxMapsObjC.TMBExpressionOperator.Floor => "floor", - MapboxMapsObjC.TMBExpressionOperator.Format => "format", - MapboxMapsObjC.TMBExpressionOperator.GeometryType => "geometry-type", - MapboxMapsObjC.TMBExpressionOperator.Get => "get", - MapboxMapsObjC.TMBExpressionOperator.Has => "has", - MapboxMapsObjC.TMBExpressionOperator.HeatmapDensity => "heatmap-density", - MapboxMapsObjC.TMBExpressionOperator.Id => "id", - MapboxMapsObjC.TMBExpressionOperator.Image => "image", - MapboxMapsObjC.TMBExpressionOperator.InExpression => "in", - MapboxMapsObjC.TMBExpressionOperator.IndexOf => "index-of", - MapboxMapsObjC.TMBExpressionOperator.Interpolate => "interpolate", - MapboxMapsObjC.TMBExpressionOperator.IsSupportedScript => "is-supported-script", - MapboxMapsObjC.TMBExpressionOperator.Length => "length", - MapboxMapsObjC.TMBExpressionOperator.LetExpression => "let", - MapboxMapsObjC.TMBExpressionOperator.LineProgress => "line-progress", - MapboxMapsObjC.TMBExpressionOperator.Literal => "literal", - MapboxMapsObjC.TMBExpressionOperator.Ln => "ln", - MapboxMapsObjC.TMBExpressionOperator.Ln2 => "ln2", - MapboxMapsObjC.TMBExpressionOperator.Log10 => "log10", - MapboxMapsObjC.TMBExpressionOperator.Log2 => "log2", - MapboxMapsObjC.TMBExpressionOperator.Match => "match", - MapboxMapsObjC.TMBExpressionOperator.Max => "max", - MapboxMapsObjC.TMBExpressionOperator.Min => "min", - MapboxMapsObjC.TMBExpressionOperator.Number => "number", - MapboxMapsObjC.TMBExpressionOperator.NumberFormat => "number-format", - MapboxMapsObjC.TMBExpressionOperator.ObjectExpression => "object", - MapboxMapsObjC.TMBExpressionOperator.Pi => "pi", - MapboxMapsObjC.TMBExpressionOperator.Pitch => "pitch", - MapboxMapsObjC.TMBExpressionOperator.Properties => "properties", - MapboxMapsObjC.TMBExpressionOperator.ResolvedLocale => "resolved-locale", - MapboxMapsObjC.TMBExpressionOperator.Rgb => "rgb", - MapboxMapsObjC.TMBExpressionOperator.Rgba => "rgba", - MapboxMapsObjC.TMBExpressionOperator.Round => "round", - MapboxMapsObjC.TMBExpressionOperator.Sin => "sin", - MapboxMapsObjC.TMBExpressionOperator.SkyRadialProgress => "sky-radial-progress", - MapboxMapsObjC.TMBExpressionOperator.Slice => "slice", - MapboxMapsObjC.TMBExpressionOperator.Sqrt => "sqrt", - MapboxMapsObjC.TMBExpressionOperator.Step => "step", - MapboxMapsObjC.TMBExpressionOperator.String => "string", - MapboxMapsObjC.TMBExpressionOperator.Tan => "tan", - MapboxMapsObjC.TMBExpressionOperator.ToBoolean => "to-boolean", - MapboxMapsObjC.TMBExpressionOperator.ToColor => "to-color", - MapboxMapsObjC.TMBExpressionOperator.ToNumber => "to-number", - MapboxMapsObjC.TMBExpressionOperator.ToRgba => "to-rgba", - MapboxMapsObjC.TMBExpressionOperator.ToString => "to-string", - MapboxMapsObjC.TMBExpressionOperator.TypeofExpression => "typeof", - MapboxMapsObjC.TMBExpressionOperator.Upcase => "upcase", - MapboxMapsObjC.TMBExpressionOperator.VarExpression => "var", - MapboxMapsObjC.TMBExpressionOperator.Within => "within", - MapboxMapsObjC.TMBExpressionOperator.Zoom => "zoom", - MapboxMapsObjC.TMBExpressionOperator.Linear => "linear", - MapboxMapsObjC.TMBExpressionOperator.Exponential => "exponential", - MapboxMapsObjC.TMBExpressionOperator.CubicBezier => "cubic-bezier" - }; - } - - public static ExpressionOperator ExpressionOperatorX(this Foundation.NSNumber value) - { - return value.ExpressionOperator().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this ExpressionOperator value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; + //return value switch + //{ + // MapboxMapsObjC.TMBExpressionOperator.Subtract => "-", + // MapboxMapsObjC.TMBExpressionOperator.Not_ => "!", + // MapboxMapsObjC.TMBExpressionOperator.Neq => "!=", + // MapboxMapsObjC.TMBExpressionOperator.Product => "*", + // MapboxMapsObjC.TMBExpressionOperator.Division => "/", + // MapboxMapsObjC.TMBExpressionOperator.Mod => "%", + // MapboxMapsObjC.TMBExpressionOperator.Pow => "^", + // MapboxMapsObjC.TMBExpressionOperator.Sum => "+", + // MapboxMapsObjC.TMBExpressionOperator.Lt => "<", + // MapboxMapsObjC.TMBExpressionOperator.Lte => "<=", + // MapboxMapsObjC.TMBExpressionOperator.Eq => "==", + // MapboxMapsObjC.TMBExpressionOperator.Gt => ">", + // MapboxMapsObjC.TMBExpressionOperator.Gte => ">=", + // MapboxMapsObjC.TMBExpressionOperator.Abs => "abs", + // MapboxMapsObjC.TMBExpressionOperator.Accumulated => "accumulated", + // MapboxMapsObjC.TMBExpressionOperator.Acos => "acos", + // MapboxMapsObjC.TMBExpressionOperator.All => "all", + // MapboxMapsObjC.TMBExpressionOperator.Any => "any", + // MapboxMapsObjC.TMBExpressionOperator.Array => "array", + // MapboxMapsObjC.TMBExpressionOperator.Asin => "asin", + // MapboxMapsObjC.TMBExpressionOperator.At => "at", + // MapboxMapsObjC.TMBExpressionOperator.Atan => "atan", + // MapboxMapsObjC.TMBExpressionOperator.Boolean => "boolean", + // MapboxMapsObjC.TMBExpressionOperator.SwitchCase => "case", + // MapboxMapsObjC.TMBExpressionOperator.Ceil => "ceil", + // MapboxMapsObjC.TMBExpressionOperator.Coalesce => "coalesce", + // MapboxMapsObjC.TMBExpressionOperator.Collator => "collator", + // MapboxMapsObjC.TMBExpressionOperator.Concat => "concat", + // MapboxMapsObjC.TMBExpressionOperator.Cos => "cos", + // MapboxMapsObjC.TMBExpressionOperator.Distance => "distance", + // MapboxMapsObjC.TMBExpressionOperator.DistanceFromCenter => "distance-from-center", + // MapboxMapsObjC.TMBExpressionOperator.Downcase => "downcase", + // MapboxMapsObjC.TMBExpressionOperator.E => "e", + // MapboxMapsObjC.TMBExpressionOperator.FeatureState => "feature-state", + // MapboxMapsObjC.TMBExpressionOperator.Floor => "floor", + // MapboxMapsObjC.TMBExpressionOperator.Format => "format", + // MapboxMapsObjC.TMBExpressionOperator.GeometryType => "geometry-type", + // MapboxMapsObjC.TMBExpressionOperator.Get => "get", + // MapboxMapsObjC.TMBExpressionOperator.Has => "has", + // MapboxMapsObjC.TMBExpressionOperator.HeatmapDensity => "heatmap-density", + // MapboxMapsObjC.TMBExpressionOperator.Id => "id", + // MapboxMapsObjC.TMBExpressionOperator.Image => "image", + // MapboxMapsObjC.TMBExpressionOperator.InExpression => "in", + // MapboxMapsObjC.TMBExpressionOperator.IndexOf => "index-of", + // MapboxMapsObjC.TMBExpressionOperator.Interpolate => "interpolate", + // MapboxMapsObjC.TMBExpressionOperator.IsSupportedScript => "is-supported-script", + // MapboxMapsObjC.TMBExpressionOperator.Length => "length", + // MapboxMapsObjC.TMBExpressionOperator.LetExpression => "let", + // MapboxMapsObjC.TMBExpressionOperator.LineProgress => "line-progress", + // MapboxMapsObjC.TMBExpressionOperator.Literal => "literal", + // MapboxMapsObjC.TMBExpressionOperator.Ln => "ln", + // MapboxMapsObjC.TMBExpressionOperator.Ln2 => "ln2", + // MapboxMapsObjC.TMBExpressionOperator.Log10 => "log10", + // MapboxMapsObjC.TMBExpressionOperator.Log2 => "log2", + // MapboxMapsObjC.TMBExpressionOperator.Match => "match", + // MapboxMapsObjC.TMBExpressionOperator.Max => "max", + // MapboxMapsObjC.TMBExpressionOperator.Min => "min", + // MapboxMapsObjC.TMBExpressionOperator.Number => "number", + // MapboxMapsObjC.TMBExpressionOperator.NumberFormat => "number-format", + // MapboxMapsObjC.TMBExpressionOperator.ObjectExpression => "object", + // MapboxMapsObjC.TMBExpressionOperator.Pi => "pi", + // MapboxMapsObjC.TMBExpressionOperator.Pitch => "pitch", + // MapboxMapsObjC.TMBExpressionOperator.Properties => "properties", + // MapboxMapsObjC.TMBExpressionOperator.ResolvedLocale => "resolved-locale", + // MapboxMapsObjC.TMBExpressionOperator.Rgb => "rgb", + // MapboxMapsObjC.TMBExpressionOperator.Rgba => "rgba", + // MapboxMapsObjC.TMBExpressionOperator.Round => "round", + // MapboxMapsObjC.TMBExpressionOperator.Sin => "sin", + // MapboxMapsObjC.TMBExpressionOperator.SkyRadialProgress => "sky-radial-progress", + // MapboxMapsObjC.TMBExpressionOperator.Slice => "slice", + // MapboxMapsObjC.TMBExpressionOperator.Sqrt => "sqrt", + // MapboxMapsObjC.TMBExpressionOperator.Step => "step", + // MapboxMapsObjC.TMBExpressionOperator.String => "string", + // MapboxMapsObjC.TMBExpressionOperator.Tan => "tan", + // MapboxMapsObjC.TMBExpressionOperator.ToBoolean => "to-boolean", + // MapboxMapsObjC.TMBExpressionOperator.ToColor => "to-color", + // MapboxMapsObjC.TMBExpressionOperator.ToNumber => "to-number", + // MapboxMapsObjC.TMBExpressionOperator.ToRgba => "to-rgba", + // MapboxMapsObjC.TMBExpressionOperator.ToString => "to-string", + // MapboxMapsObjC.TMBExpressionOperator.TypeofExpression => "typeof", + // MapboxMapsObjC.TMBExpressionOperator.Upcase => "upcase", + // MapboxMapsObjC.TMBExpressionOperator.VarExpression => "var", + // MapboxMapsObjC.TMBExpressionOperator.Within => "within", + // MapboxMapsObjC.TMBExpressionOperator.Zoom => "zoom", + // MapboxMapsObjC.TMBExpressionOperator.Linear => "linear", + // MapboxMapsObjC.TMBExpressionOperator.Exponential => "exponential", + // MapboxMapsObjC.TMBExpressionOperator.CubicBezier => "cubic-bezier" + //}; } } #endif diff --git a/src/libs/Mapbox.Maui/Models/MapTappedPosition.cs b/src/libs/Mapbox.Maui/Models/MapTappedPosition.cs new file mode 100644 index 0000000..21bd49a --- /dev/null +++ b/src/libs/Mapbox.Maui/Models/MapTappedPosition.cs @@ -0,0 +1,5 @@ +namespace MapboxMaui; + +public record MapTappedPosition( + ScreenPosition ScreenPosition, + IPosition MapPosition); diff --git a/src/libs/Mapbox.Maui/Models/MapboxStyle.cs b/src/libs/Mapbox.Maui/Models/MapboxStyle.cs index 8eb5334..7cd4eb8 100644 --- a/src/libs/Mapbox.Maui/Models/MapboxStyle.cs +++ b/src/libs/Mapbox.Maui/Models/MapboxStyle.cs @@ -18,30 +18,35 @@ public MapboxStyle(string value) public override string ToString() => $"Uri: {Value}"; + /** + * Mapbox Standard: A dynamic and performant 3D style that is the default for Mapbox maps. + */ + public static readonly MapboxStyle STANDARD = (MapboxStyle)"mapbox://styles/mapbox/standard"; + /** * Mapbox Streets: A complete base map, perfect for incorporating your own data. Using this * constant means your map style will always use the latest version and may change as we * improve the style. */ - public static readonly MapboxStyle MAPBOX_STREETS = (MapboxStyle)"mapbox://styles/mapbox/streets-v11"; + public static readonly MapboxStyle MAPBOX_STREETS = (MapboxStyle)"mapbox://styles/mapbox/streets-v12"; /** * Outdoors: A general-purpose style tailored to outdoor activities. Using this constant means * your map style will always use the latest version and may change as we improve the style. */ - public static readonly MapboxStyle OUTDOORS = (MapboxStyle)"mapbox://styles/mapbox/outdoors-v11"; + public static readonly MapboxStyle OUTDOORS = (MapboxStyle)"mapbox://styles/mapbox/outdoors-v12"; /** * Light: Subtle light backdrop for data visualizations. Using this constant means your map * style will always use the latest version and may change as we improve the style. */ - public static readonly MapboxStyle LIGHT = (MapboxStyle)"mapbox://styles/mapbox/light-v10"; + public static readonly MapboxStyle LIGHT = (MapboxStyle)"mapbox://styles/mapbox/light-v11"; /** * Dark: Subtle dark backdrop for data visualizations. Using this constant means your map style * will always use the latest version and may change as we improve the style. */ - public static readonly MapboxStyle DARK = (MapboxStyle)"mapbox://styles/mapbox/dark-v10"; + public static readonly MapboxStyle DARK = (MapboxStyle)"mapbox://styles/mapbox/dark-v11"; /** * Satellite: A beautiful global satellite and aerial imagery layer. Using this constant means @@ -54,7 +59,7 @@ public MapboxStyle(string value) * constant means your map style will always use the latest version and may change as we * improve the style. */ - public static readonly MapboxStyle SATELLITE_STREETS = (MapboxStyle)"mapbox://styles/mapbox/satellite-streets-v11"; + public static readonly MapboxStyle SATELLITE_STREETS = (MapboxStyle)"mapbox://styles/mapbox/satellite-streets-v12"; /** * Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently diff --git a/src/libs/Mapbox.Maui/Models/Query/QueriedFeature.cs b/src/libs/Mapbox.Maui/Models/Query/QueriedFeature.cs index a915d83..be63336 100644 --- a/src/libs/Mapbox.Maui/Models/Query/QueriedFeature.cs +++ b/src/libs/Mapbox.Maui/Models/Query/QueriedFeature.cs @@ -7,4 +7,5 @@ public class QueriedFeature public Feature Feature { get; internal set; } public string Source { get; internal set; } public string SourceLayer { get; internal set; } + public IDisposable State { get; set; } } \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Models/Query/RendereredQueriedFeature.cs b/src/libs/Mapbox.Maui/Models/Query/RendereredQueriedFeature.cs new file mode 100644 index 0000000..2c538ef --- /dev/null +++ b/src/libs/Mapbox.Maui/Models/Query/RendereredQueriedFeature.cs @@ -0,0 +1,7 @@ +namespace MapboxMaui.Query; + +public class QueriedRenderedFeature +{ + public QueriedFeature QueriedFeature { get; internal set; } + public string[] Layers { get; internal set; } +} \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Models/Styles/Enums.cs b/src/libs/Mapbox.Maui/Models/Styles/Enums.cs index afde1f0..512b74f 100644 --- a/src/libs/Mapbox.Maui/Models/Styles/Enums.cs +++ b/src/libs/Mapbox.Maui/Models/Styles/Enums.cs @@ -8,26 +8,26 @@ namespace MapboxMaui; { /// The layer is shown. - public static readonly Visibility Visible = new ("visible"); + public static readonly Visibility Visible = new("visible"); /// The layer is not shown. - public static readonly Visibility None = new ("none"); + public static readonly Visibility None = new("none"); public string Value { get; } private Visibility(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(Visibility value) => value.Value; - public static implicit operator Visibility(string value) => new (value); + public static implicit operator Visibility(string value) => new(value); } -public static partial class VisibilityExtensions {} +public static partial class VisibilityExtensions { } #if IOS partial class VisibilityExtensions { public static MapboxMapsObjC.TMBVisibility ToPlatform(this Visibility value) { - return value.Value switch + return value.Value switch { "visible" => MapboxMapsObjC.TMBVisibility.Visible, "none" => MapboxMapsObjC.TMBVisibility.None @@ -36,21 +36,9 @@ public static MapboxMapsObjC.TMBVisibility ToPlatform(this Visibility value) public static Visibility ToPlatform(this MapboxMapsObjC.TMBVisibility value) { - return value switch - { - MapboxMapsObjC.TMBVisibility.Visible => "visible", - MapboxMapsObjC.TMBVisibility.None => "none" - }; - } - - public static Visibility VisibilityX(this Foundation.NSNumber value) - { - return value.Visibility().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this Visibility value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value == TMBVisibility.Visible + ? Visibility.Visible + : Visibility.None; } } #endif @@ -73,55 +61,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Visibi { /// A cap with a squared-off end which is drawn to the exact endpoint of the line. - public static readonly LineCap Butt = new ("butt"); + public static readonly LineCap Butt = new("butt"); /// A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line. - public static readonly LineCap Round = new ("round"); + public static readonly LineCap Round = new("round"); /// A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width. - public static readonly LineCap Square = new ("square"); + public static readonly LineCap Square = new("square"); public string Value { get; } private LineCap(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(LineCap value) => value.Value; - public static implicit operator LineCap(string value) => new (value); + public static implicit operator LineCap(string value) => new(value); } -public static partial class LineCapExtensions {} +public static partial class LineCapExtensions { } #if IOS partial class LineCapExtensions { public static MapboxMapsObjC.TMBLineCap ToPlatform(this LineCap value) { - return value.Value switch - { - "butt" => MapboxMapsObjC.TMBLineCap.Butt, - "round" => MapboxMapsObjC.TMBLineCap.Round, - "square" => MapboxMapsObjC.TMBLineCap.Square - }; + return new TMBLineCap(value.Value); } public static LineCap ToPlatform(this MapboxMapsObjC.TMBLineCap value) { - return value switch - { - MapboxMapsObjC.TMBLineCap.Butt => "butt", - MapboxMapsObjC.TMBLineCap.Round => "round", - MapboxMapsObjC.TMBLineCap.Square => "square" - }; - } - - public static LineCap LineCapX(this Foundation.NSNumber value) - { - return value.LineCap().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this LineCap value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -144,55 +112,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.LineCa { /// A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width. - public static readonly LineJoin Bevel = new ("bevel"); + public static readonly LineJoin Bevel = new("bevel"); /// A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line. - public static readonly LineJoin Round = new ("round"); + public static readonly LineJoin Round = new("round"); /// A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet. - public static readonly LineJoin Miter = new ("miter"); + public static readonly LineJoin Miter = new("miter"); public string Value { get; } private LineJoin(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(LineJoin value) => value.Value; - public static implicit operator LineJoin(string value) => new (value); + public static implicit operator LineJoin(string value) => new(value); } -public static partial class LineJoinExtensions {} +public static partial class LineJoinExtensions { } #if IOS partial class LineJoinExtensions { public static MapboxMapsObjC.TMBLineJoin ToPlatform(this LineJoin value) { - return value.Value switch - { - "bevel" => MapboxMapsObjC.TMBLineJoin.Bevel, - "round" => MapboxMapsObjC.TMBLineJoin.Round, - "miter" => MapboxMapsObjC.TMBLineJoin.Miter - }; + return new (value.Value); } public static LineJoin ToPlatform(this MapboxMapsObjC.TMBLineJoin value) { - return value switch - { - MapboxMapsObjC.TMBLineJoin.Bevel => "bevel", - MapboxMapsObjC.TMBLineJoin.Round => "round", - MapboxMapsObjC.TMBLineJoin.Miter => "miter" - }; - } - - public static LineJoin LineJoinX(this Foundation.NSNumber value) - { - return value.LineJoin().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this LineJoin value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -215,85 +163,53 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.LineJo { /// The center of the icon is placed closest to the anchor. - public static readonly IconAnchor Center = new ("center"); + public static readonly IconAnchor Center = new("center"); /// The left side of the icon is placed closest to the anchor. - public static readonly IconAnchor Left = new ("left"); + public static readonly IconAnchor Left = new("left"); /// The right side of the icon is placed closest to the anchor. - public static readonly IconAnchor Right = new ("right"); + public static readonly IconAnchor Right = new("right"); /// The top of the icon is placed closest to the anchor. - public static readonly IconAnchor Top = new ("top"); + public static readonly IconAnchor Top = new("top"); /// The bottom of the icon is placed closest to the anchor. - public static readonly IconAnchor Bottom = new ("bottom"); + public static readonly IconAnchor Bottom = new("bottom"); /// The top left corner of the icon is placed closest to the anchor. - public static readonly IconAnchor TopLeft = new ("top-left"); + public static readonly IconAnchor TopLeft = new("top-left"); /// The top right corner of the icon is placed closest to the anchor. - public static readonly IconAnchor TopRight = new ("top-right"); + public static readonly IconAnchor TopRight = new("top-right"); /// The bottom left corner of the icon is placed closest to the anchor. - public static readonly IconAnchor BottomLeft = new ("bottom-left"); + public static readonly IconAnchor BottomLeft = new("bottom-left"); /// The bottom right corner of the icon is placed closest to the anchor. - public static readonly IconAnchor BottomRight = new ("bottom-right"); + public static readonly IconAnchor BottomRight = new("bottom-right"); public string Value { get; } private IconAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(IconAnchor value) => value.Value; - public static implicit operator IconAnchor(string value) => new (value); + public static implicit operator IconAnchor(string value) => new(value); } -public static partial class IconAnchorExtensions {} +public static partial class IconAnchorExtensions { } #if IOS partial class IconAnchorExtensions { public static MapboxMapsObjC.TMBIconAnchor ToPlatform(this IconAnchor value) { - return value.Value switch - { - "center" => MapboxMapsObjC.TMBIconAnchor.Center, - "left" => MapboxMapsObjC.TMBIconAnchor.Left, - "right" => MapboxMapsObjC.TMBIconAnchor.Right, - "top" => MapboxMapsObjC.TMBIconAnchor.Top, - "bottom" => MapboxMapsObjC.TMBIconAnchor.Bottom, - "top-left" => MapboxMapsObjC.TMBIconAnchor.TopLeft, - "top-right" => MapboxMapsObjC.TMBIconAnchor.TopRight, - "bottom-left" => MapboxMapsObjC.TMBIconAnchor.BottomLeft, - "bottom-right" => MapboxMapsObjC.TMBIconAnchor.BottomRight - }; + return new(value.Value); } public static IconAnchor ToPlatform(this MapboxMapsObjC.TMBIconAnchor value) { - return value switch - { - MapboxMapsObjC.TMBIconAnchor.Center => "center", - MapboxMapsObjC.TMBIconAnchor.Left => "left", - MapboxMapsObjC.TMBIconAnchor.Right => "right", - MapboxMapsObjC.TMBIconAnchor.Top => "top", - MapboxMapsObjC.TMBIconAnchor.Bottom => "bottom", - MapboxMapsObjC.TMBIconAnchor.TopLeft => "top-left", - MapboxMapsObjC.TMBIconAnchor.TopRight => "top-right", - MapboxMapsObjC.TMBIconAnchor.BottomLeft => "bottom-left", - MapboxMapsObjC.TMBIconAnchor.BottomRight => "bottom-right" - }; - } - - public static IconAnchor IconAnchorX(this Foundation.NSNumber value) - { - return value.IconAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this IconAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -316,55 +232,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.IconAn { /// The icon is aligned to the plane of the map. - public static readonly IconPitchAlignment Map = new ("map"); + public static readonly IconPitchAlignment Map = new("map"); /// The icon is aligned to the plane of the viewport. - public static readonly IconPitchAlignment Viewport = new ("viewport"); + public static readonly IconPitchAlignment Viewport = new("viewport"); /// Automatically matches the value of {@link ICON_ROTATION_ALIGNMENT}. - public static readonly IconPitchAlignment Auto = new ("auto"); + public static readonly IconPitchAlignment Auto = new("auto"); public string Value { get; } private IconPitchAlignment(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(IconPitchAlignment value) => value.Value; - public static implicit operator IconPitchAlignment(string value) => new (value); + public static implicit operator IconPitchAlignment(string value) => new(value); } -public static partial class IconPitchAlignmentExtensions {} +public static partial class IconPitchAlignmentExtensions { } #if IOS partial class IconPitchAlignmentExtensions { public static MapboxMapsObjC.TMBIconPitchAlignment ToPlatform(this IconPitchAlignment value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBIconPitchAlignment.Map, - "viewport" => MapboxMapsObjC.TMBIconPitchAlignment.Viewport, - "auto" => MapboxMapsObjC.TMBIconPitchAlignment.Auto - }; + return new(value.Value); } public static IconPitchAlignment ToPlatform(this MapboxMapsObjC.TMBIconPitchAlignment value) { - return value switch - { - MapboxMapsObjC.TMBIconPitchAlignment.Map => "map", - MapboxMapsObjC.TMBIconPitchAlignment.Viewport => "viewport", - MapboxMapsObjC.TMBIconPitchAlignment.Auto => "auto" - }; - } - - public static IconPitchAlignment IconPitchAlignmentX(this Foundation.NSNumber value) - { - return value.IconPitchAlignment().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this IconPitchAlignment value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -387,55 +283,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.IconPi { /// When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, aligns icon x-axes with the line. - public static readonly IconRotationAlignment Map = new ("map"); + public static readonly IconRotationAlignment Map = new("map"); /// Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}. - public static readonly IconRotationAlignment Viewport = new ("viewport"); + public static readonly IconRotationAlignment Viewport = new("viewport"); /// When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}. - public static readonly IconRotationAlignment Auto = new ("auto"); + public static readonly IconRotationAlignment Auto = new("auto"); public string Value { get; } private IconRotationAlignment(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(IconRotationAlignment value) => value.Value; - public static implicit operator IconRotationAlignment(string value) => new (value); + public static implicit operator IconRotationAlignment(string value) => new(value); } -public static partial class IconRotationAlignmentExtensions {} +public static partial class IconRotationAlignmentExtensions { } #if IOS partial class IconRotationAlignmentExtensions { public static MapboxMapsObjC.TMBIconRotationAlignment ToPlatform(this IconRotationAlignment value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBIconRotationAlignment.Map, - "viewport" => MapboxMapsObjC.TMBIconRotationAlignment.Viewport, - "auto" => MapboxMapsObjC.TMBIconRotationAlignment.Auto - }; + return new(value.Value); } public static IconRotationAlignment ToPlatform(this MapboxMapsObjC.TMBIconRotationAlignment value) { - return value switch - { - MapboxMapsObjC.TMBIconRotationAlignment.Map => "map", - MapboxMapsObjC.TMBIconRotationAlignment.Viewport => "viewport", - MapboxMapsObjC.TMBIconRotationAlignment.Auto => "auto" - }; - } - - public static IconRotationAlignment IconRotationAlignmentX(this Foundation.NSNumber value) - { - return value.IconRotationAlignment().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this IconRotationAlignment value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -458,60 +334,38 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.IconRo { /// The icon is displayed at its intrinsic aspect ratio. - public static readonly IconTextFit None = new ("none"); + public static readonly IconTextFit None = new("none"); /// The icon is scaled in the x-dimension to fit the width of the text. - public static readonly IconTextFit Width = new ("width"); + public static readonly IconTextFit Width = new("width"); /// The icon is scaled in the y-dimension to fit the height of the text. - public static readonly IconTextFit Height = new ("height"); + public static readonly IconTextFit Height = new("height"); /// The icon is scaled in both x- and y-dimensions. - public static readonly IconTextFit Both = new ("both"); + public static readonly IconTextFit Both = new("both"); public string Value { get; } private IconTextFit(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(IconTextFit value) => value.Value; - public static implicit operator IconTextFit(string value) => new (value); + public static implicit operator IconTextFit(string value) => new(value); } -public static partial class IconTextFitExtensions {} +public static partial class IconTextFitExtensions { } #if IOS partial class IconTextFitExtensions { public static MapboxMapsObjC.TMBIconTextFit ToPlatform(this IconTextFit value) { - return value.Value switch - { - "none" => MapboxMapsObjC.TMBIconTextFit.None, - "width" => MapboxMapsObjC.TMBIconTextFit.Width, - "height" => MapboxMapsObjC.TMBIconTextFit.Height, - "both" => MapboxMapsObjC.TMBIconTextFit.Both - }; + return new(value.Value); } public static IconTextFit ToPlatform(this MapboxMapsObjC.TMBIconTextFit value) { - return value switch - { - MapboxMapsObjC.TMBIconTextFit.None => "none", - MapboxMapsObjC.TMBIconTextFit.Width => "width", - MapboxMapsObjC.TMBIconTextFit.Height => "height", - MapboxMapsObjC.TMBIconTextFit.Both => "both" - }; - } - - public static IconTextFit IconTextFitX(this Foundation.NSNumber value) - { - return value.IconTextFit().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this IconTextFit value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -534,55 +388,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.IconTe { /// The label is placed at the point where the geometry is located. - public static readonly SymbolPlacement Point = new ("point"); + public static readonly SymbolPlacement Point = new("point"); /// The label is placed along the line of the geometry. Can only be used on LineString and Polygon geometries. - public static readonly SymbolPlacement Line = new ("line"); + public static readonly SymbolPlacement Line = new("line"); /// The label is placed at the center of the line of the geometry. Can only be used on LineString and Polygon geometries. Note that a single feature in a vector tile may contain multiple line geometries. - public static readonly SymbolPlacement LineCenter = new ("line-center"); + public static readonly SymbolPlacement LineCenter = new("line-center"); public string Value { get; } private SymbolPlacement(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(SymbolPlacement value) => value.Value; - public static implicit operator SymbolPlacement(string value) => new (value); + public static implicit operator SymbolPlacement(string value) => new(value); } -public static partial class SymbolPlacementExtensions {} +public static partial class SymbolPlacementExtensions { } #if IOS partial class SymbolPlacementExtensions { public static MapboxMapsObjC.TMBSymbolPlacement ToPlatform(this SymbolPlacement value) { - return value.Value switch - { - "point" => MapboxMapsObjC.TMBSymbolPlacement.Point, - "line" => MapboxMapsObjC.TMBSymbolPlacement.Line, - "line-center" => MapboxMapsObjC.TMBSymbolPlacement.LineCenter - }; + return new(value.Value); } public static SymbolPlacement ToPlatform(this MapboxMapsObjC.TMBSymbolPlacement value) { - return value switch - { - MapboxMapsObjC.TMBSymbolPlacement.Point => "point", - MapboxMapsObjC.TMBSymbolPlacement.Line => "line", - MapboxMapsObjC.TMBSymbolPlacement.LineCenter => "line-center" - }; - } - - public static SymbolPlacement SymbolPlacementX(this Foundation.NSNumber value) - { - return value.SymbolPlacement().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this SymbolPlacement value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -605,55 +439,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Symbol { /// Sorts symbols by symbol sort key if set. Otherwise, sorts symbols by their y-position relative to the viewport if {@link ICON_ALLOW_OVERLAP} or {@link TEXT_ALLOW_OVERLAP} is set to {@link TRUE} or {@link ICON_IGNORE_PLACEMENT} or {@link TEXT_IGNORE_PLACEMENT} is {@link FALSE}. - public static readonly SymbolZOrder Auto = new ("auto"); + public static readonly SymbolZOrder Auto = new("auto"); /// Sorts symbols by their y-position relative to the viewport if {@link ICON_ALLOW_OVERLAP} or {@link TEXT_ALLOW_OVERLAP} is set to {@link TRUE} or {@link ICON_IGNORE_PLACEMENT} or {@link TEXT_IGNORE_PLACEMENT} is {@link FALSE}. - public static readonly SymbolZOrder ViewportY = new ("viewport-y"); + public static readonly SymbolZOrder ViewportY = new("viewport-y"); /// Sorts symbols by symbol sort key if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data. - public static readonly SymbolZOrder Source = new ("source"); + public static readonly SymbolZOrder Source = new("source"); public string Value { get; } private SymbolZOrder(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(SymbolZOrder value) => value.Value; - public static implicit operator SymbolZOrder(string value) => new (value); + public static implicit operator SymbolZOrder(string value) => new(value); } -public static partial class SymbolZOrderExtensions {} +public static partial class SymbolZOrderExtensions { } #if IOS partial class SymbolZOrderExtensions { public static MapboxMapsObjC.TMBSymbolZOrder ToPlatform(this SymbolZOrder value) { - return value.Value switch - { - "auto" => MapboxMapsObjC.TMBSymbolZOrder.Auto, - "viewport-y" => MapboxMapsObjC.TMBSymbolZOrder.ViewportY, - "source" => MapboxMapsObjC.TMBSymbolZOrder.Source - }; + return new(value.Value); } public static SymbolZOrder ToPlatform(this MapboxMapsObjC.TMBSymbolZOrder value) { - return value switch - { - MapboxMapsObjC.TMBSymbolZOrder.Auto => "auto", - MapboxMapsObjC.TMBSymbolZOrder.ViewportY => "viewport-y", - MapboxMapsObjC.TMBSymbolZOrder.Source => "source" - }; - } - - public static SymbolZOrder SymbolZOrderX(this Foundation.NSNumber value) - { - return value.SymbolZOrder().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this SymbolZOrder value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -676,85 +490,53 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Symbol { /// The center of the text is placed closest to the anchor. - public static readonly TextAnchor Center = new ("center"); + public static readonly TextAnchor Center = new("center"); /// The left side of the text is placed closest to the anchor. - public static readonly TextAnchor Left = new ("left"); + public static readonly TextAnchor Left = new("left"); /// The right side of the text is placed closest to the anchor. - public static readonly TextAnchor Right = new ("right"); + public static readonly TextAnchor Right = new("right"); /// The top of the text is placed closest to the anchor. - public static readonly TextAnchor Top = new ("top"); + public static readonly TextAnchor Top = new("top"); /// The bottom of the text is placed closest to the anchor. - public static readonly TextAnchor Bottom = new ("bottom"); + public static readonly TextAnchor Bottom = new("bottom"); /// The top left corner of the text is placed closest to the anchor. - public static readonly TextAnchor TopLeft = new ("top-left"); + public static readonly TextAnchor TopLeft = new("top-left"); /// The top right corner of the text is placed closest to the anchor. - public static readonly TextAnchor TopRight = new ("top-right"); + public static readonly TextAnchor TopRight = new("top-right"); /// The bottom left corner of the text is placed closest to the anchor. - public static readonly TextAnchor BottomLeft = new ("bottom-left"); + public static readonly TextAnchor BottomLeft = new("bottom-left"); /// The bottom right corner of the text is placed closest to the anchor. - public static readonly TextAnchor BottomRight = new ("bottom-right"); + public static readonly TextAnchor BottomRight = new("bottom-right"); public string Value { get; } private TextAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextAnchor value) => value.Value; - public static implicit operator TextAnchor(string value) => new (value); + public static implicit operator TextAnchor(string value) => new(value); } -public static partial class TextAnchorExtensions {} +public static partial class TextAnchorExtensions { } #if IOS partial class TextAnchorExtensions { public static MapboxMapsObjC.TMBTextAnchor ToPlatform(this TextAnchor value) { - return value.Value switch - { - "center" => MapboxMapsObjC.TMBTextAnchor.Center, - "left" => MapboxMapsObjC.TMBTextAnchor.Left, - "right" => MapboxMapsObjC.TMBTextAnchor.Right, - "top" => MapboxMapsObjC.TMBTextAnchor.Top, - "bottom" => MapboxMapsObjC.TMBTextAnchor.Bottom, - "top-left" => MapboxMapsObjC.TMBTextAnchor.TopLeft, - "top-right" => MapboxMapsObjC.TMBTextAnchor.TopRight, - "bottom-left" => MapboxMapsObjC.TMBTextAnchor.BottomLeft, - "bottom-right" => MapboxMapsObjC.TMBTextAnchor.BottomRight - }; + return new(value.Value); } public static TextAnchor ToPlatform(this MapboxMapsObjC.TMBTextAnchor value) { - return value switch - { - MapboxMapsObjC.TMBTextAnchor.Center => "center", - MapboxMapsObjC.TMBTextAnchor.Left => "left", - MapboxMapsObjC.TMBTextAnchor.Right => "right", - MapboxMapsObjC.TMBTextAnchor.Top => "top", - MapboxMapsObjC.TMBTextAnchor.Bottom => "bottom", - MapboxMapsObjC.TMBTextAnchor.TopLeft => "top-left", - MapboxMapsObjC.TMBTextAnchor.TopRight => "top-right", - MapboxMapsObjC.TMBTextAnchor.BottomLeft => "bottom-left", - MapboxMapsObjC.TMBTextAnchor.BottomRight => "bottom-right" - }; - } - - public static TextAnchor TextAnchorX(this Foundation.NSNumber value) - { - return value.TextAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -777,60 +559,38 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextAn { /// The text is aligned towards the anchor position. - public static readonly TextJustify Auto = new ("auto"); + public static readonly TextJustify Auto = new("auto"); /// The text is aligned to the left. - public static readonly TextJustify Left = new ("left"); + public static readonly TextJustify Left = new("left"); /// The text is centered. - public static readonly TextJustify Center = new ("center"); + public static readonly TextJustify Center = new("center"); /// The text is aligned to the right. - public static readonly TextJustify Right = new ("right"); + public static readonly TextJustify Right = new("right"); public string Value { get; } private TextJustify(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextJustify value) => value.Value; - public static implicit operator TextJustify(string value) => new (value); + public static implicit operator TextJustify(string value) => new(value); } -public static partial class TextJustifyExtensions {} +public static partial class TextJustifyExtensions { } #if IOS partial class TextJustifyExtensions { public static MapboxMapsObjC.TMBTextJustify ToPlatform(this TextJustify value) { - return value.Value switch - { - "auto" => MapboxMapsObjC.TMBTextJustify.Auto, - "left" => MapboxMapsObjC.TMBTextJustify.Left, - "center" => MapboxMapsObjC.TMBTextJustify.Center, - "right" => MapboxMapsObjC.TMBTextJustify.Right - }; + return new(value.Value); } public static TextJustify ToPlatform(this MapboxMapsObjC.TMBTextJustify value) { - return value switch - { - MapboxMapsObjC.TMBTextJustify.Auto => "auto", - MapboxMapsObjC.TMBTextJustify.Left => "left", - MapboxMapsObjC.TMBTextJustify.Center => "center", - MapboxMapsObjC.TMBTextJustify.Right => "right" - }; - } - - public static TextJustify TextJustifyX(this Foundation.NSNumber value) - { - return value.TextJustify().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextJustify value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -853,55 +613,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextJu { /// The text is aligned to the plane of the map. - public static readonly TextPitchAlignment Map = new ("map"); + public static readonly TextPitchAlignment Map = new("map"); /// The text is aligned to the plane of the viewport. - public static readonly TextPitchAlignment Viewport = new ("viewport"); + public static readonly TextPitchAlignment Viewport = new("viewport"); /// Automatically matches the value of {@link TEXT_ROTATION_ALIGNMENT}. - public static readonly TextPitchAlignment Auto = new ("auto"); + public static readonly TextPitchAlignment Auto = new("auto"); public string Value { get; } private TextPitchAlignment(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextPitchAlignment value) => value.Value; - public static implicit operator TextPitchAlignment(string value) => new (value); + public static implicit operator TextPitchAlignment(string value) => new(value); } -public static partial class TextPitchAlignmentExtensions {} +public static partial class TextPitchAlignmentExtensions { } #if IOS partial class TextPitchAlignmentExtensions { public static MapboxMapsObjC.TMBTextPitchAlignment ToPlatform(this TextPitchAlignment value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBTextPitchAlignment.Map, - "viewport" => MapboxMapsObjC.TMBTextPitchAlignment.Viewport, - "auto" => MapboxMapsObjC.TMBTextPitchAlignment.Auto - }; + return new(value.Value); } public static TextPitchAlignment ToPlatform(this MapboxMapsObjC.TMBTextPitchAlignment value) { - return value switch - { - MapboxMapsObjC.TMBTextPitchAlignment.Map => "map", - MapboxMapsObjC.TMBTextPitchAlignment.Viewport => "viewport", - MapboxMapsObjC.TMBTextPitchAlignment.Auto => "auto" - }; - } - - public static TextPitchAlignment TextPitchAlignmentX(this Foundation.NSNumber value) - { - return value.TextPitchAlignment().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextPitchAlignment value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -924,55 +664,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextPi { /// When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, aligns text x-axes with the line. - public static readonly TextRotationAlignment Map = new ("map"); + public static readonly TextRotationAlignment Map = new("map"); /// Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}. - public static readonly TextRotationAlignment Viewport = new ("viewport"); + public static readonly TextRotationAlignment Viewport = new("viewport"); /// When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE} or {@link Property#SYMBOL_PLACEMENT_LINE_CENTER}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}. - public static readonly TextRotationAlignment Auto = new ("auto"); + public static readonly TextRotationAlignment Auto = new("auto"); public string Value { get; } private TextRotationAlignment(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextRotationAlignment value) => value.Value; - public static implicit operator TextRotationAlignment(string value) => new (value); + public static implicit operator TextRotationAlignment(string value) => new(value); } -public static partial class TextRotationAlignmentExtensions {} +public static partial class TextRotationAlignmentExtensions { } #if IOS partial class TextRotationAlignmentExtensions { public static MapboxMapsObjC.TMBTextRotationAlignment ToPlatform(this TextRotationAlignment value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBTextRotationAlignment.Map, - "viewport" => MapboxMapsObjC.TMBTextRotationAlignment.Viewport, - "auto" => MapboxMapsObjC.TMBTextRotationAlignment.Auto - }; + return new(value.Value); } public static TextRotationAlignment ToPlatform(this MapboxMapsObjC.TMBTextRotationAlignment value) { - return value switch - { - MapboxMapsObjC.TMBTextRotationAlignment.Map => "map", - MapboxMapsObjC.TMBTextRotationAlignment.Viewport => "viewport", - MapboxMapsObjC.TMBTextRotationAlignment.Auto => "auto" - }; - } - - public static TextRotationAlignment TextRotationAlignmentX(this Foundation.NSNumber value) - { - return value.TextRotationAlignment().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextRotationAlignment value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -995,55 +715,35 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextRo { /// The text is not altered. - public static readonly TextTransform None = new ("none"); + public static readonly TextTransform None = new("none"); /// Forces all letters to be displayed in uppercase. - public static readonly TextTransform Uppercase = new ("uppercase"); + public static readonly TextTransform Uppercase = new("uppercase"); /// Forces all letters to be displayed in lowercase. - public static readonly TextTransform Lowercase = new ("lowercase"); + public static readonly TextTransform Lowercase = new("lowercase"); public string Value { get; } private TextTransform(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextTransform value) => value.Value; - public static implicit operator TextTransform(string value) => new (value); + public static implicit operator TextTransform(string value) => new(value); } -public static partial class TextTransformExtensions {} +public static partial class TextTransformExtensions { } #if IOS partial class TextTransformExtensions { public static MapboxMapsObjC.TMBTextTransform ToPlatform(this TextTransform value) { - return value.Value switch - { - "none" => MapboxMapsObjC.TMBTextTransform.None, - "uppercase" => MapboxMapsObjC.TMBTextTransform.Uppercase, - "lowercase" => MapboxMapsObjC.TMBTextTransform.Lowercase - }; + return new(value.Value); } public static TextTransform ToPlatform(this MapboxMapsObjC.TMBTextTransform value) { - return value switch - { - MapboxMapsObjC.TMBTextTransform.None => "none", - MapboxMapsObjC.TMBTextTransform.Uppercase => "uppercase", - MapboxMapsObjC.TMBTextTransform.Lowercase => "lowercase" - }; - } - - public static TextTransform TextTransformX(this Foundation.NSNumber value) - { - return value.TextTransform().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextTransform value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1066,50 +766,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextTr { /// The fill is translated relative to the map. - public static readonly FillTranslateAnchor Map = new ("map"); + public static readonly FillTranslateAnchor Map = new("map"); /// The fill is translated relative to the viewport. - public static readonly FillTranslateAnchor Viewport = new ("viewport"); + public static readonly FillTranslateAnchor Viewport = new("viewport"); public string Value { get; } private FillTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(FillTranslateAnchor value) => value.Value; - public static implicit operator FillTranslateAnchor(string value) => new (value); + public static implicit operator FillTranslateAnchor(string value) => new(value); } -public static partial class FillTranslateAnchorExtensions {} +public static partial class FillTranslateAnchorExtensions { } #if IOS partial class FillTranslateAnchorExtensions { public static MapboxMapsObjC.TMBFillTranslateAnchor ToPlatform(this FillTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBFillTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBFillTranslateAnchor.Viewport - }; + return new(value.Value); } public static FillTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBFillTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBFillTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBFillTranslateAnchor.Viewport => "viewport" - }; - } - - public static FillTranslateAnchor FillTranslateAnchorX(this Foundation.NSNumber value) - { - return value.FillTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this FillTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1132,50 +814,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.FillTr { /// The line is translated relative to the map. - public static readonly LineTranslateAnchor Map = new ("map"); + public static readonly LineTranslateAnchor Map = new("map"); /// The line is translated relative to the viewport. - public static readonly LineTranslateAnchor Viewport = new ("viewport"); + public static readonly LineTranslateAnchor Viewport = new("viewport"); public string Value { get; } private LineTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(LineTranslateAnchor value) => value.Value; - public static implicit operator LineTranslateAnchor(string value) => new (value); + public static implicit operator LineTranslateAnchor(string value) => new(value); } -public static partial class LineTranslateAnchorExtensions {} +public static partial class LineTranslateAnchorExtensions { } #if IOS partial class LineTranslateAnchorExtensions { public static MapboxMapsObjC.TMBLineTranslateAnchor ToPlatform(this LineTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBLineTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBLineTranslateAnchor.Viewport - }; + return new(value.Value); } public static LineTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBLineTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBLineTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBLineTranslateAnchor.Viewport => "viewport" - }; - } - - public static LineTranslateAnchor LineTranslateAnchorX(this Foundation.NSNumber value) - { - return value.LineTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this LineTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1198,50 +862,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.LineTr { /// Icons are translated relative to the map. - public static readonly IconTranslateAnchor Map = new ("map"); + public static readonly IconTranslateAnchor Map = new("map"); /// Icons are translated relative to the viewport. - public static readonly IconTranslateAnchor Viewport = new ("viewport"); + public static readonly IconTranslateAnchor Viewport = new("viewport"); public string Value { get; } private IconTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(IconTranslateAnchor value) => value.Value; - public static implicit operator IconTranslateAnchor(string value) => new (value); + public static implicit operator IconTranslateAnchor(string value) => new(value); } -public static partial class IconTranslateAnchorExtensions {} +public static partial class IconTranslateAnchorExtensions { } #if IOS partial class IconTranslateAnchorExtensions { public static MapboxMapsObjC.TMBIconTranslateAnchor ToPlatform(this IconTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBIconTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBIconTranslateAnchor.Viewport - }; + return new(value.Value); } public static IconTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBIconTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBIconTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBIconTranslateAnchor.Viewport => "viewport" - }; - } - - public static IconTranslateAnchor IconTranslateAnchorX(this Foundation.NSNumber value) - { - return value.IconTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this IconTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1264,50 +910,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.IconTr { /// The text is translated relative to the map. - public static readonly TextTranslateAnchor Map = new ("map"); + public static readonly TextTranslateAnchor Map = new("map"); /// The text is translated relative to the viewport. - public static readonly TextTranslateAnchor Viewport = new ("viewport"); + public static readonly TextTranslateAnchor Viewport = new("viewport"); public string Value { get; } private TextTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextTranslateAnchor value) => value.Value; - public static implicit operator TextTranslateAnchor(string value) => new (value); + public static implicit operator TextTranslateAnchor(string value) => new(value); } -public static partial class TextTranslateAnchorExtensions {} +public static partial class TextTranslateAnchorExtensions { } #if IOS partial class TextTranslateAnchorExtensions { public static MapboxMapsObjC.TMBTextTranslateAnchor ToPlatform(this TextTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBTextTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBTextTranslateAnchor.Viewport - }; + return new(value.Value); } public static TextTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBTextTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBTextTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBTextTranslateAnchor.Viewport => "viewport" - }; - } - - public static TextTranslateAnchor TextTranslateAnchorX(this Foundation.NSNumber value) - { - return value.TextTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1330,50 +958,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.TextTr { /// The circle is aligned to the plane of the map. - public static readonly CirclePitchAlignment Map = new ("map"); + public static readonly CirclePitchAlignment Map = new("map"); /// The circle is aligned to the plane of the viewport. - public static readonly CirclePitchAlignment Viewport = new ("viewport"); + public static readonly CirclePitchAlignment Viewport = new("viewport"); public string Value { get; } private CirclePitchAlignment(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(CirclePitchAlignment value) => value.Value; - public static implicit operator CirclePitchAlignment(string value) => new (value); + public static implicit operator CirclePitchAlignment(string value) => new(value); } -public static partial class CirclePitchAlignmentExtensions {} +public static partial class CirclePitchAlignmentExtensions { } #if IOS partial class CirclePitchAlignmentExtensions { public static MapboxMapsObjC.TMBCirclePitchAlignment ToPlatform(this CirclePitchAlignment value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBCirclePitchAlignment.Map, - "viewport" => MapboxMapsObjC.TMBCirclePitchAlignment.Viewport - }; + return new(value.Value); } public static CirclePitchAlignment ToPlatform(this MapboxMapsObjC.TMBCirclePitchAlignment value) { - return value switch - { - MapboxMapsObjC.TMBCirclePitchAlignment.Map => "map", - MapboxMapsObjC.TMBCirclePitchAlignment.Viewport => "viewport" - }; - } - - public static CirclePitchAlignment CirclePitchAlignmentX(this Foundation.NSNumber value) - { - return value.CirclePitchAlignment().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this CirclePitchAlignment value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1396,50 +1006,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Circle { /// Circles are scaled according to their apparent distance to the camera. - public static readonly CirclePitchScale Map = new ("map"); + public static readonly CirclePitchScale Map = new("map"); /// Circles are not scaled. - public static readonly CirclePitchScale Viewport = new ("viewport"); + public static readonly CirclePitchScale Viewport = new("viewport"); public string Value { get; } private CirclePitchScale(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(CirclePitchScale value) => value.Value; - public static implicit operator CirclePitchScale(string value) => new (value); + public static implicit operator CirclePitchScale(string value) => new(value); } -public static partial class CirclePitchScaleExtensions {} +public static partial class CirclePitchScaleExtensions { } #if IOS partial class CirclePitchScaleExtensions { public static MapboxMapsObjC.TMBCirclePitchScale ToPlatform(this CirclePitchScale value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBCirclePitchScale.Map, - "viewport" => MapboxMapsObjC.TMBCirclePitchScale.Viewport - }; + return new(value.Value); } public static CirclePitchScale ToPlatform(this MapboxMapsObjC.TMBCirclePitchScale value) { - return value switch - { - MapboxMapsObjC.TMBCirclePitchScale.Map => "map", - MapboxMapsObjC.TMBCirclePitchScale.Viewport => "viewport" - }; - } - - public static CirclePitchScale CirclePitchScaleX(this Foundation.NSNumber value) - { - return value.CirclePitchScale().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this CirclePitchScale value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1462,50 +1054,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Circle { /// The circle is translated relative to the map. - public static readonly CircleTranslateAnchor Map = new ("map"); + public static readonly CircleTranslateAnchor Map = new("map"); /// The circle is translated relative to the viewport. - public static readonly CircleTranslateAnchor Viewport = new ("viewport"); + public static readonly CircleTranslateAnchor Viewport = new("viewport"); public string Value { get; } private CircleTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(CircleTranslateAnchor value) => value.Value; - public static implicit operator CircleTranslateAnchor(string value) => new (value); + public static implicit operator CircleTranslateAnchor(string value) => new(value); } -public static partial class CircleTranslateAnchorExtensions {} +public static partial class CircleTranslateAnchorExtensions { } #if IOS partial class CircleTranslateAnchorExtensions { public static MapboxMapsObjC.TMBCircleTranslateAnchor ToPlatform(this CircleTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBCircleTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBCircleTranslateAnchor.Viewport - }; + return new(value.Value); } public static CircleTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBCircleTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBCircleTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBCircleTranslateAnchor.Viewport => "viewport" - }; - } - - public static CircleTranslateAnchor CircleTranslateAnchorX(this Foundation.NSNumber value) - { - return value.CircleTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this CircleTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1528,50 +1102,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Circle { /// The fill extrusion is translated relative to the map. - public static readonly FillExtrusionTranslateAnchor Map = new ("map"); + public static readonly FillExtrusionTranslateAnchor Map = new("map"); /// The fill extrusion is translated relative to the viewport. - public static readonly FillExtrusionTranslateAnchor Viewport = new ("viewport"); + public static readonly FillExtrusionTranslateAnchor Viewport = new("viewport"); public string Value { get; } private FillExtrusionTranslateAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(FillExtrusionTranslateAnchor value) => value.Value; - public static implicit operator FillExtrusionTranslateAnchor(string value) => new (value); + public static implicit operator FillExtrusionTranslateAnchor(string value) => new(value); } -public static partial class FillExtrusionTranslateAnchorExtensions {} +public static partial class FillExtrusionTranslateAnchorExtensions { } #if IOS partial class FillExtrusionTranslateAnchorExtensions { public static MapboxMapsObjC.TMBFillExtrusionTranslateAnchor ToPlatform(this FillExtrusionTranslateAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBFillExtrusionTranslateAnchor.Map, - "viewport" => MapboxMapsObjC.TMBFillExtrusionTranslateAnchor.Viewport - }; + return new(value.Value); } public static FillExtrusionTranslateAnchor ToPlatform(this MapboxMapsObjC.TMBFillExtrusionTranslateAnchor value) { - return value switch - { - MapboxMapsObjC.TMBFillExtrusionTranslateAnchor.Map => "map", - MapboxMapsObjC.TMBFillExtrusionTranslateAnchor.Viewport => "viewport" - }; - } - - public static FillExtrusionTranslateAnchor FillExtrusionTranslateAnchorX(this Foundation.NSNumber value) - { - return value.FillExtrusionTranslateAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this FillExtrusionTranslateAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1594,50 +1150,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.FillEx { /// (Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled - public static readonly RasterResampling Linear = new ("linear"); + public static readonly RasterResampling Linear = new("linear"); /// Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled - public static readonly RasterResampling Nearest = new ("nearest"); + public static readonly RasterResampling Nearest = new("nearest"); public string Value { get; } private RasterResampling(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(RasterResampling value) => value.Value; - public static implicit operator RasterResampling(string value) => new (value); + public static implicit operator RasterResampling(string value) => new(value); } -public static partial class RasterResamplingExtensions {} +public static partial class RasterResamplingExtensions { } #if IOS partial class RasterResamplingExtensions { public static MapboxMapsObjC.TMBRasterResampling ToPlatform(this RasterResampling value) { - return value.Value switch - { - "linear" => MapboxMapsObjC.TMBRasterResampling.Linear, - "nearest" => MapboxMapsObjC.TMBRasterResampling.Nearest - }; + return new(value.Value); } public static RasterResampling ToPlatform(this MapboxMapsObjC.TMBRasterResampling value) { - return value switch - { - MapboxMapsObjC.TMBRasterResampling.Linear => "linear", - MapboxMapsObjC.TMBRasterResampling.Nearest => "nearest" - }; - } - - public static RasterResampling RasterResamplingX(this Foundation.NSNumber value) - { - return value.RasterResampling().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this RasterResampling value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1660,50 +1198,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Raster { /// The hillshade illumination is relative to the north direction. - public static readonly HillshadeIlluminationAnchor Map = new ("map"); + public static readonly HillshadeIlluminationAnchor Map = new("map"); /// The hillshade illumination is relative to the top of the viewport. - public static readonly HillshadeIlluminationAnchor Viewport = new ("viewport"); + public static readonly HillshadeIlluminationAnchor Viewport = new("viewport"); public string Value { get; } private HillshadeIlluminationAnchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(HillshadeIlluminationAnchor value) => value.Value; - public static implicit operator HillshadeIlluminationAnchor(string value) => new (value); + public static implicit operator HillshadeIlluminationAnchor(string value) => new(value); } -public static partial class HillshadeIlluminationAnchorExtensions {} +public static partial class HillshadeIlluminationAnchorExtensions { } #if IOS partial class HillshadeIlluminationAnchorExtensions { public static MapboxMapsObjC.TMBHillshadeIlluminationAnchor ToPlatform(this HillshadeIlluminationAnchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBHillshadeIlluminationAnchor.Map, - "viewport" => MapboxMapsObjC.TMBHillshadeIlluminationAnchor.Viewport - }; + return new(value.Value); } public static HillshadeIlluminationAnchor ToPlatform(this MapboxMapsObjC.TMBHillshadeIlluminationAnchor value) { - return value switch - { - MapboxMapsObjC.TMBHillshadeIlluminationAnchor.Map => "map", - MapboxMapsObjC.TMBHillshadeIlluminationAnchor.Viewport => "viewport" - }; - } - - public static HillshadeIlluminationAnchor HillshadeIlluminationAnchorX(this Foundation.NSNumber value) - { - return value.HillshadeIlluminationAnchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this HillshadeIlluminationAnchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1726,50 +1246,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Hillsh { /// Renders the sky with a gradient that can be configured with {@link SKY_GRADIENT_RADIUS} and {@link SKY_GRADIENT}. - public static readonly SkyType Gradient = new ("gradient"); + public static readonly SkyType Gradient = new("gradient"); /// Renders the sky with a simulated atmospheric scattering algorithm, the sun direction can be attached to the light position or explicitly set through {@link SKY_ATMOSPHERE_SUN}. - public static readonly SkyType Atmosphere = new ("atmosphere"); + public static readonly SkyType Atmosphere = new("atmosphere"); public string Value { get; } private SkyType(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(SkyType value) => value.Value; - public static implicit operator SkyType(string value) => new (value); + public static implicit operator SkyType(string value) => new(value); } -public static partial class SkyTypeExtensions {} +public static partial class SkyTypeExtensions { } #if IOS partial class SkyTypeExtensions { public static MapboxMapsObjC.TMBSkyType ToPlatform(this SkyType value) { - return value.Value switch - { - "gradient" => MapboxMapsObjC.TMBSkyType.Gradient, - "atmosphere" => MapboxMapsObjC.TMBSkyType.Atmosphere - }; + return new(value.Value); } public static SkyType ToPlatform(this MapboxMapsObjC.TMBSkyType value) { - return value switch - { - MapboxMapsObjC.TMBSkyType.Gradient => "gradient", - MapboxMapsObjC.TMBSkyType.Atmosphere => "atmosphere" - }; - } - - public static SkyType SkyTypeX(this Foundation.NSNumber value) - { - return value.SkyType().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this SkyType value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1792,50 +1294,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.SkyTyp { /// The position of the light source is aligned to the rotation of the map. - public static readonly Anchor Map = new ("map"); + public static readonly Anchor Map = new("map"); /// The position of the light source is aligned to the rotation of the viewport. - public static readonly Anchor Viewport = new ("viewport"); + public static readonly Anchor Viewport = new("viewport"); public string Value { get; } private Anchor(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(Anchor value) => value.Value; - public static implicit operator Anchor(string value) => new (value); + public static implicit operator Anchor(string value) => new(value); } -public static partial class AnchorExtensions {} +public static partial class AnchorExtensions { } #if IOS partial class AnchorExtensions { public static MapboxMapsObjC.TMBAnchor ToPlatform(this Anchor value) { - return value.Value switch - { - "map" => MapboxMapsObjC.TMBAnchor.Map, - "viewport" => MapboxMapsObjC.TMBAnchor.Viewport - }; + return new(value.Value); } public static Anchor ToPlatform(this MapboxMapsObjC.TMBAnchor value) { - return value switch - { - MapboxMapsObjC.TMBAnchor.Map => "map", - MapboxMapsObjC.TMBAnchor.Viewport => "viewport" - }; - } - - public static Anchor AnchorX(this Foundation.NSNumber value) - { - return value.Anchor().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this Anchor value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1858,50 +1342,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Anchor { /// The Mercator projection is the default projection. - public static readonly StyleProjectionName Mercator = new ("mercator"); + public static readonly StyleProjectionName Mercator = new("mercator"); /// A globe projection. - public static readonly StyleProjectionName Globe = new ("globe"); + public static readonly StyleProjectionName Globe = new("globe"); public string Value { get; } private StyleProjectionName(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(StyleProjectionName value) => value.Value; - public static implicit operator StyleProjectionName(string value) => new (value); + public static implicit operator StyleProjectionName(string value) => new(value); } -public static partial class StyleProjectionNameExtensions {} +public static partial class StyleProjectionNameExtensions { } #if IOS partial class StyleProjectionNameExtensions { public static MapboxMapsObjC.TMBStyleProjectionName ToPlatform(this StyleProjectionName value) { - return value.Value switch - { - "mercator" => MapboxMapsObjC.TMBStyleProjectionName.Mercator, - "globe" => MapboxMapsObjC.TMBStyleProjectionName.Globe - }; + return new(value.Value); } public static StyleProjectionName ToPlatform(this MapboxMapsObjC.TMBStyleProjectionName value) { - return value switch - { - MapboxMapsObjC.TMBStyleProjectionName.Mercator => "mercator", - MapboxMapsObjC.TMBStyleProjectionName.Globe => "globe" - }; - } - - public static StyleProjectionName StyleProjectionNameX(this Foundation.NSNumber value) - { - return value.StyleProjectionName().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this StyleProjectionName value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -1924,50 +1390,32 @@ public static Com.Mapbox.Maps.Extension.Style.Layers.Properties.Generated.Projec { /// If a text's language supports horizontal writing mode, symbols would be laid out horizontally. - public static readonly TextWritingMode Horizontal = new ("horizontal"); + public static readonly TextWritingMode Horizontal = new("horizontal"); /// If a text's language supports vertical writing mode, symbols would be laid out vertically. - public static readonly TextWritingMode Vertical = new ("vertical"); + public static readonly TextWritingMode Vertical = new("vertical"); public string Value { get; } private TextWritingMode(string value) => Value = value; - public override string ToString() => Value; + public override string ToString() => Value; public static implicit operator string(TextWritingMode value) => value.Value; - public static implicit operator TextWritingMode(string value) => new (value); + public static implicit operator TextWritingMode(string value) => new(value); } -public static partial class TextWritingModeExtensions {} +public static partial class TextWritingModeExtensions { } #if IOS partial class TextWritingModeExtensions { public static MapboxMapsObjC.TMBTextWritingMode ToPlatform(this TextWritingMode value) { - return value.Value switch - { - "horizontal" => MapboxMapsObjC.TMBTextWritingMode.Horizontal, - "vertical" => MapboxMapsObjC.TMBTextWritingMode.Vertical - }; + return new(value.Value); } public static TextWritingMode ToPlatform(this MapboxMapsObjC.TMBTextWritingMode value) { - return value switch - { - MapboxMapsObjC.TMBTextWritingMode.Horizontal => "horizontal", - MapboxMapsObjC.TMBTextWritingMode.Vertical => "vertical" - }; - } - - public static TextWritingMode TextWritingModeX(this Foundation.NSNumber value) - { - return value.TextWritingMode().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this TextWritingMode value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif diff --git a/src/libs/Mapbox.Maui/Models/Styles/Layers/LayerType.cs b/src/libs/Mapbox.Maui/Models/Styles/Layers/LayerType.cs index 4d7cd7f..f923c95 100644 --- a/src/libs/Mapbox.Maui/Models/Styles/Layers/LayerType.cs +++ b/src/libs/Mapbox.Maui/Models/Styles/Layers/LayerType.cs @@ -40,10 +40,6 @@ namespace MapboxMaui; /// Layer representing the sky public static readonly LayerType Sky = new ("sky"); - // @available(*, deprecated, message: "Unsupported layer type") - public static readonly LayerType Model = new ("model"); - - public string Value { get; } private LayerType(string value) => Value = value; @@ -58,50 +54,12 @@ partial class LayerTypeExtensions { public static MapboxMapsObjC.TMBLayerType ToPlatform(this LayerType value) { - return value.Value switch - { - "fill" => MapboxMapsObjC.TMBLayerType.Fill, - "line" => MapboxMapsObjC.TMBLayerType.Line, - "symbol" => MapboxMapsObjC.TMBLayerType.Symbol, - "circle" => MapboxMapsObjC.TMBLayerType.Circle, - "heatmap" => MapboxMapsObjC.TMBLayerType.Heatmap, - "fill-extrusion" => MapboxMapsObjC.TMBLayerType.FillExtrusion, - "raster" => MapboxMapsObjC.TMBLayerType.Raster, - "hillshade" => MapboxMapsObjC.TMBLayerType.Hillshade, - "background" => MapboxMapsObjC.TMBLayerType.Background, - "location-indicator" => MapboxMapsObjC.TMBLayerType.LocationIndicator, - "sky" => MapboxMapsObjC.TMBLayerType.Sky, - "model" => MapboxMapsObjC.TMBLayerType.Model - }; + return new (value.Value); } public static LayerType ToPlatform(this MapboxMapsObjC.TMBLayerType value) { - return value switch - { - MapboxMapsObjC.TMBLayerType.Fill => "fill", - MapboxMapsObjC.TMBLayerType.Line => "line", - MapboxMapsObjC.TMBLayerType.Symbol => "symbol", - MapboxMapsObjC.TMBLayerType.Circle => "circle", - MapboxMapsObjC.TMBLayerType.Heatmap => "heatmap", - MapboxMapsObjC.TMBLayerType.FillExtrusion => "fill-extrusion", - MapboxMapsObjC.TMBLayerType.Raster => "raster", - MapboxMapsObjC.TMBLayerType.Hillshade => "hillshade", - MapboxMapsObjC.TMBLayerType.Background => "background", - MapboxMapsObjC.TMBLayerType.LocationIndicator => "location-indicator", - MapboxMapsObjC.TMBLayerType.Sky => "sky", - MapboxMapsObjC.TMBLayerType.Model => "model" - }; - } - - public static LayerType LayerTypeX(this Foundation.NSNumber value) - { - return value.LayerType().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this LayerType value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif diff --git a/src/libs/Mapbox.Maui/Models/Styles/SourceType.cs b/src/libs/Mapbox.Maui/Models/Styles/SourceType.cs index 1c1d761..c246769 100644 --- a/src/libs/Mapbox.Maui/Models/Styles/SourceType.cs +++ b/src/libs/Mapbox.Maui/Models/Styles/SourceType.cs @@ -40,38 +40,12 @@ partial class SourceTypeExtensions { public static MapboxMapsObjC.TMBSourceType ToPlatform(this SourceType value) { - return value.Value switch - { - "vector" => MapboxMapsObjC.TMBSourceType.Vector, - "raster" => MapboxMapsObjC.TMBSourceType.Raster, - "raster-dem" => MapboxMapsObjC.TMBSourceType.RasterDem, - "geojson" => MapboxMapsObjC.TMBSourceType.GeoJson, - "image" => MapboxMapsObjC.TMBSourceType.Image, - "model" => MapboxMapsObjC.TMBSourceType.Model - }; + return new(value.Value); } public static SourceType ToPlatform(this MapboxMapsObjC.TMBSourceType value) { - return value switch - { - MapboxMapsObjC.TMBSourceType.Vector => "vector", - MapboxMapsObjC.TMBSourceType.Raster => "raster", - MapboxMapsObjC.TMBSourceType.RasterDem => "raster-dem", - MapboxMapsObjC.TMBSourceType.GeoJson => "geojson", - MapboxMapsObjC.TMBSourceType.Image => "image", - MapboxMapsObjC.TMBSourceType.Model => "model" - }; - } - - public static SourceType SourceTypeX(this Foundation.NSNumber value) - { - return value.SourceType().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this SourceType value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif diff --git a/src/libs/Mapbox.Maui/Models/Styles/Sources/SourceProperties.cs b/src/libs/Mapbox.Maui/Models/Styles/Sources/SourceProperties.cs index 55be780..b15d7ff 100644 --- a/src/libs/Mapbox.Maui/Models/Styles/Sources/SourceProperties.cs +++ b/src/libs/Mapbox.Maui/Models/Styles/Sources/SourceProperties.cs @@ -29,30 +29,12 @@ partial class SchemeExtensions { public static MapboxMapsObjC.TMBScheme ToPlatform(this Scheme value) { - return value.Value switch - { - "xyz" => MapboxMapsObjC.TMBScheme.Xyz, - "tms" => MapboxMapsObjC.TMBScheme.Tms - }; + return new (value.Value); } public static Scheme ToPlatform(this MapboxMapsObjC.TMBScheme value) { - return value switch - { - MapboxMapsObjC.TMBScheme.Xyz => "xyz", - MapboxMapsObjC.TMBScheme.Tms => "tms" - }; - } - - public static Scheme SchemeX(this Foundation.NSNumber value) - { - return value.Scheme().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this Scheme value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif @@ -93,30 +75,12 @@ partial class EncodingExtensions { public static MapboxMapsObjC.TMBEncoding ToPlatform(this Encoding value) { - return value.Value switch - { - "terrarium" => MapboxMapsObjC.TMBEncoding.Terrarium, - "mapbox" => MapboxMapsObjC.TMBEncoding.Mapbox - }; + return new(value.Value); } public static Encoding ToPlatform(this MapboxMapsObjC.TMBEncoding value) { - return value switch - { - MapboxMapsObjC.TMBEncoding.Terrarium => "terrarium", - MapboxMapsObjC.TMBEncoding.Mapbox => "mapbox" - }; - } - - public static Encoding EncodingX(this Foundation.NSNumber value) - { - return value.Encoding().ToPlatform(); - } - - public static Foundation.NSNumber AsNumber(this Encoding value) - { - return Foundation.NSNumber.FromInt32((int)ToPlatform(value)); + return value.RawValue; } } #endif diff --git a/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs index 2adc0d6..3f482d8 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs @@ -1,4 +1,6 @@ namespace MapboxMaui; +using Android.Content.Res; +using Android.Util; using MapboxMapsCameraOptions = Com.Mapbox.Maps.CameraOptions; using PlatformValue = Com.Mapbox.Bindgen.Value; using MapboxTerrain = Com.Mapbox.Maps.Extension.Style.Terrain.Generated.Terrain; @@ -14,6 +16,16 @@ static class AdditionalExtensions { + internal static DisplayMetrics Metrics; + + internal static double PixelToPoint(this double pixel) + { + Metrics ??= Resources.System?.DisplayMetrics; + if (Metrics == null) return 0; + + return pixel / Metrics.Density; + } + internal static Java.Lang.Boolean ToPlatform(this bool xvalue) { return new Java.Lang.Boolean(xvalue); @@ -299,12 +311,12 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions) { var cameraOptionsBuilder = new MapboxMapsCameraOptions.Builder(); - if (cameraOptions.Center.HasValue) + if (cameraOptions.Center is not null) { cameraOptionsBuilder.Center( Com.Mapbox.Geojson.Point.FromLngLat( - cameraOptions.Center.Value.Y, - cameraOptions.Center.Value.X + cameraOptions.Center.Longitude, + cameraOptions.Center.Latitude )); } @@ -333,7 +345,7 @@ public static MapboxMapsCameraOptions ToNative(this CameraOptions cameraOptions) )); } - if (cameraOptions.Anchor.HasValue) + if (cameraOptions.Anchor is not null) { cameraOptionsBuilder.Anchor(new ScreenCoordinate( cameraOptions.Anchor.Value.X, diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationExtensions.cs index d11a2c5..e6bffed 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationExtensions.cs @@ -1,9 +1,9 @@ namespace MapboxMaui.Annotations; -using PlatformPolygonAnnotationOptions = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolygonAnnotationOptions; -using PlatformCircleAnnotationOptions = Com.Mapbox.Maps.Plugin.Annotation.Generated.CircleAnnotationOptions; -using PlatformPointAnnotationOptions = Com.Mapbox.Maps.Plugin.Annotation.Generated.PointAnnotationOptions; -using PlatformPolylineAnnotationOptions = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolylineAnnotationOptions; +using PlatformPolygonAnnotationOptions = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotationOptions; +using PlatformCircleAnnotationOptions = Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotationOptions; +using PlatformPointAnnotationOptions = Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotationOptions; +using PlatformPolylineAnnotationOptions = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolylineAnnotationOptions; public static class AnnotationExtensions { diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationManager.cs index 40d4b71..f9481ea 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/AnnotationManager.cs @@ -1,6 +1,6 @@ namespace MapboxMaui.Annotations; -using IPlatformAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.IAnnotationManager; +using IPlatformAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.IAnnotationManager; public abstract partial class AnnotationManager : IAnnotationManager diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/CircleAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/CircleAnnotationManager.cs index 86cbc84..da81f7e 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/CircleAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/CircleAnnotationManager.cs @@ -1,6 +1,6 @@ namespace MapboxMaui.Annotations; -using PlatformCircleAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.CircleAnnotationManager; +using PlatformCircleAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotationManager; public partial class CircleAnnotationManager : AnnotationManager @@ -51,7 +51,7 @@ public override void AddAnnotations(params CircleAnnotation[] xitems) for (int i = 0; i < platformAnnotations.Count; i++) { - var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugin.Annotation.Generated.CircleAnnotation; + var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotation; xitems[i].Id = item.Id.ToString(); } } @@ -65,12 +65,10 @@ public override void RemoveAnnotations(params string[] annotationIDs) { foreach (var xid in annotationIDs) { - if (!long.TryParse(xid, out var id)) continue; - var item = nativeManager .Annotations - .Cast() - .FirstOrDefault(x => x.Id == id); + .Cast() + .FirstOrDefault(x => x.Id == xid); if (item == null) continue; diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PointAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PointAnnotationManager.cs index 995034d..120dd6a 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PointAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PointAnnotationManager.cs @@ -1,6 +1,6 @@ namespace MapboxMaui.Annotations; -using PlatformPointAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PointAnnotationManager; +using PlatformPointAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotationManager; public partial class PointAnnotationManager : AnnotationManager @@ -50,16 +50,6 @@ public IconRotationAlignment? IconRotationAlignment get => nativeManager.IconRotationAlignment?.GetValue(); set => nativeManager.IconRotationAlignment = value?.ToPlatform(); } - public IconTextFit? IconTextFit - { - get => nativeManager.IconTextFit?.GetValue(); - set => nativeManager.IconTextFit = value?.ToPlatform(); - } - public double[] IconTextFitPadding - { - get => nativeManager.IconTextFitPadding.GetValue(); - set => nativeManager.IconTextFitPadding = value?.ToPlatform(); - } public bool? SymbolAvoidEdges { get => nativeManager.SymbolAvoidEdges?.BooleanValue(); @@ -163,12 +153,6 @@ public TextTranslateAnchor? TextTranslateAnchor get => nativeManager.TextTranslateAnchor?.GetValue(); set => nativeManager.TextTranslateAnchor = value?.ToPlatform(); } - public double? TextLineHeight - { - get => nativeManager.TextLineHeight?.DoubleValue(); - set => nativeManager.TextLineHeight = value?.ToPlatform(); - } - public override void AddAnnotations(params PointAnnotation[] xitems) { var items = xitems @@ -179,7 +163,7 @@ public override void AddAnnotations(params PointAnnotation[] xitems) for (int i = 0; i < platformAnnotations.Count; i++) { - var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugin.Annotation.Generated.PointAnnotation; + var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotation; xitems[i].Id = item.Id.ToString(); } } @@ -193,12 +177,10 @@ public override void RemoveAnnotations(params string[] annotationIDs) { foreach (var xid in annotationIDs) { - if (!long.TryParse(xid, out var id)) continue; - var item = nativeManager .Annotations - .Cast() - .FirstOrDefault(x => x.Id == id); + .Cast() + .FirstOrDefault(x => x.Id == xid); if (item == null) continue; diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolygonAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolygonAnnotationManager.cs index aae176f..1da8a79 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolygonAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolygonAnnotationManager.cs @@ -1,6 +1,6 @@ namespace MapboxMaui.Annotations; -using PlatformPolygonAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolygonAnnotationManager; +using PlatformPolygonAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotationManager; partial class PolygonAnnotationManager : AnnotationManager @@ -46,7 +46,7 @@ public override void AddAnnotations(params PolygonAnnotation[] xitems) for (int i = 0; i < platformAnnotations.Count; i++) { - var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugin.Annotation.Generated.PolygonAnnotation; + var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotation; xitems[i].Id = item.Id.ToString(); } } @@ -58,13 +58,11 @@ public override void RemoveAllAnnotations() public override void RemoveAnnotations(params string[] annotationIDs) { - foreach (var xid in annotationIDs) + foreach (var id in annotationIDs) { - if (!long.TryParse(xid, out var id)) continue; - var item = nativeManager .Annotations - .Cast() + .Cast() .FirstOrDefault(x => x.Id == id); if (item == null) continue; diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolylineAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolylineAnnotationManager.cs index fc71b43..b179e91 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolylineAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Annotations/PolylineAnnotationManager.cs @@ -1,6 +1,6 @@ namespace MapboxMaui.Annotations; -using PlatformPolylineAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolylineAnnotationManager; +using PlatformPolylineAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolylineAnnotationManager; partial class PolylineAnnotationManager : AnnotationManager @@ -62,7 +62,7 @@ public override void AddAnnotations(params PolylineAnnotation[] xitems) for (int i = 0; i < platformAnnotations.Count; i++) { - var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugin.Annotation.Generated.PolylineAnnotation; + var item = platformAnnotations[i] as Com.Mapbox.Maps.Plugins.Annotations.Generated.PolylineAnnotation; xitems[i].Id = item.Id.ToString(); } } @@ -76,12 +76,10 @@ public override void RemoveAnnotations(params string[] annotationIDs) { foreach (var xid in annotationIDs) { - if (!long.TryParse(xid, out var id)) continue; - var item = nativeManager .Annotations - .Cast() - .FirstOrDefault(x => x.Id == id); + .Cast() + .FirstOrDefault(x => x.Id == xid); if (item == null) continue; diff --git a/src/libs/Mapbox.Maui/Platforms/Android/ClusterOptionsExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/ClusterOptionsExtensions.cs index 2fd8838..0d98740 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/ClusterOptionsExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/ClusterOptionsExtensions.cs @@ -6,10 +6,10 @@ namespace MapboxMaui; public static class ClusterOptionsExtensions { - public static new Com.Mapbox.Maps.Plugin.Annotation.ClusterOptions ToPlatform(this ClusterOptions clusterOptions) + public static new Com.Mapbox.Maps.Plugins.Annotations.ClusterOptions ToPlatform(this ClusterOptions clusterOptions) => clusterOptions == null ? null - : new Com.Mapbox.Maps.Plugin.Annotation.ClusterOptions( + : new Com.Mapbox.Maps.Plugins.Annotations.ClusterOptions( true, (long)clusterOptions.ClusterRadius, clusterOptions.CircleRadius?.Expression?.ToPlatformValue(), diff --git a/src/libs/Mapbox.Maui/Platforms/Android/GeometryExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/GeometryExtensions.cs index 99d3935..73cb3c7 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/GeometryExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/GeometryExtensions.cs @@ -1,4 +1,5 @@ -using GeoJSON.Text.Geometry; +using Com.Mapbox.Maps; +using GeoJSON.Text.Geometry; using Point = Microsoft.Maui.Graphics.Point; namespace MapboxMaui; @@ -7,11 +8,37 @@ public static class GeometryExtensions { internal static Com.Mapbox.Geojson.Point ToGeoPoint(this GeoJSON.Text.Geometry.IPosition xvalue) { - return Com.Mapbox.Geojson.Point.FromLngLat( + return xvalue.Altitude is not null + ? Com.Mapbox.Geojson.Point.FromLngLat( + xvalue.Longitude, + xvalue.Latitude, + xvalue.Altitude.Value) + : Com.Mapbox.Geojson.Point.FromLngLat( xvalue.Longitude, xvalue.Latitude); } + public static IPosition ToMapPosition(this Com.Mapbox.Geojson.Point point) + { + return new MapPosition( + point.Latitude(), + point.Longitude(), + point.Altitude()); + } + + internal static MapTappedPosition ToMapTappedPosition(this Com.Mapbox.Geojson.Point point, ScreenCoordinate screenCoordinate) + { + return new MapTappedPosition( + new ScreenPosition( + screenCoordinate.GetX().PixelToPoint(), + screenCoordinate.GetY().PixelToPoint()), + new MapPosition( + point.Latitude(), + point.Longitude(), + point.HasAltitude ? point.Altitude() : null) + ); + } + internal static Com.Mapbox.Geojson.IGeometry ToNative(this GeoJSON.Text.Geometry.IGeometryObject xvalue) { return xvalue switch @@ -67,6 +94,11 @@ internal static Com.Mapbox.Geojson.Point ToNative(this Point xvalue) return Com.Mapbox.Geojson.Point.FromLngLat(xvalue.Y, xvalue.X); } + internal static Com.Mapbox.Maps.ScreenCoordinate ToScreenCoordinate(this Point xvalue) + { + return new Com.Mapbox.Maps.ScreenCoordinate(xvalue.Y, xvalue.X); + } + internal static GeoJSON.Text.Feature.Feature ToX(this Com.Mapbox.Geojson.Feature src) => new GeoJSON.Text.Feature.Feature( src.Geometry().ToX(), @@ -79,7 +111,7 @@ internal static IGeometryObject ToX(this Com.Mapbox.Geojson.IGeometry src) { case Com.Mapbox.Geojson.Point point: return new GeoJSON.Text.Geometry.Point( - new Position( + new MapPosition( point.Latitude(), point.Longitude(), point.HasAltitude ? point.Altitude() : null ) diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxFragment.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxFragment.cs index 82e0f2f..ff1816f 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/MapboxFragment.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxFragment.cs @@ -6,10 +6,11 @@ using Android.OS; using System; using Android.Runtime; -using Com.Mapbox.Maps.Plugin.Delegates.Listeners; +using Com.Mapbox.Maps.Plugins.Delegates.Listeners; using Com.Mapbox.Maps.Extension.Observable.Eventdata; -using Com.Mapbox.Maps.Plugin.Gestures; +using Com.Mapbox.Maps.Plugins.Gestures; using Com.Mapbox.Geojson; +using Com.Mapbox.Common; public partial class MapboxFragment : Fragment { @@ -17,6 +18,7 @@ public partial class MapboxFragment : Fragment public event Action StyleLoaded; public event Action MapLoaded; public event Action MapClicked; + public event Action MapLongClicked; public MapView MapView { get; private set; } @@ -39,21 +41,12 @@ public MapboxFragment(IntPtr javaReference, JniHandleOwnership transfer) public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - if (string.IsNullOrWhiteSpace(MapboxViewHandler.ACCESS_TOKEN)) + if (!string.IsNullOrWhiteSpace(MapboxViewHandler.ACCESS_TOKEN)) { - return new MapView(Context); + MapboxOptions.AccessToken = MapboxViewHandler.ACCESS_TOKEN; } - var resourceOptionsManager = ResourceOptionsManager.CompanionField.GetDefault( - Context, - MapboxViewHandler.ACCESS_TOKEN - ); - var initOptions = new MapInitOptions( - Context, - resourceOptionsManager?.ResourceOptions - ); - - return MapView = new MapView(Context, initOptions); + return MapView = new MapView(Context); } public override void OnViewCreated(View view, Bundle savedInstanceState) @@ -65,6 +58,7 @@ public override void OnViewCreated(View view, Bundle savedInstanceState) MapView.MapboxMap.AddOnMapLoadedListener(this); GesturesUtils.AddOnMapClickListener(MapView.MapboxMap, this); + GesturesUtils.AddOnMapLongClickListener(MapView.MapboxMap, this); } public override void OnStart() @@ -110,25 +104,15 @@ partial class MapboxFragment : IOnStyleLoadedListener , IOnMapLoadedListener , IOnMapClickListener + , IOnMapLongClickListener { public bool OnMapClick(Point point) { if (MapClicked is null) return false; + + var screenCoordinate = MapView.MapboxMap.PixelForCoordinate(point); - var xpoint = new Microsoft.Maui.Graphics.Point( - point.Latitude(), - point.Longitude()); - MapClicked?.Invoke(new MapTappedPosition - { - ScreenPosition = xpoint, - Point = new GeoJSON.Text.Geometry.Point( - new GeoJSON.Text.Geometry.Position( - point.Latitude(), - point.Longitude(), - point.HasAltitude ? point.Altitude() : null - ) - ) - }); + MapClicked?.Invoke(point.ToMapTappedPosition(screenCoordinate)); return true; } @@ -141,4 +125,14 @@ public void OnStyleLoaded(StyleLoadedEventData eventData) { StyleLoaded?.Invoke(MapView); } + + public bool OnMapLongClick(Point point) + { + if (MapLongClicked is null) return false; + + var screenCoordinate = MapView.MapboxMap.PixelForCoordinate(point); + + MapLongClicked?.Invoke(point.ToMapTappedPosition(screenCoordinate)); + return true; + } } diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Annotations.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Annotations.cs index 36ed56c..230e6d7 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Annotations.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Annotations.cs @@ -1,10 +1,10 @@ namespace MapboxMaui; -using PlatformPolygonAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolygonAnnotationManager; -using PlatformCircleAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.CircleAnnotationManager; -using PlatformPointAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PointAnnotationManager; -using PlatformPolylineAnnotationManager = Com.Mapbox.Maps.Plugin.Annotation.Generated.PolylineAnnotationManager; -using Com.Mapbox.Maps.Plugin.Annotation; +using PlatformPolygonAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolygonAnnotationManager; +using PlatformCircleAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.CircleAnnotationManager; +using PlatformPointAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PointAnnotationManager; +using PlatformPolylineAnnotationManager = Com.Mapbox.Maps.Plugins.Annotations.Generated.PolylineAnnotationManager; +using Com.Mapbox.Maps.Plugins.Annotations; using MapboxMaui.Annotations; using MapboxMaui.Styles; @@ -18,7 +18,7 @@ public IPolygonAnnotationManager CreatePolygonAnnotationManager( if (mapView == null) return null; - var nativeManager = AnnotationPluginImplKt + var nativeManager = AnnotationsUtils .GetAnnotations(mapView) .CreateAnnotationManager( AnnotationType.PolygonAnnotation, @@ -36,7 +36,7 @@ public ICircleAnnotationManager CreateCircleAnnotationManager( if (mapView == null) return null; - var nativeManager = AnnotationPluginImplKt + var nativeManager = AnnotationsUtils .GetAnnotations(mapView) .CreateAnnotationManager( AnnotationType.CircleAnnotation, @@ -59,11 +59,12 @@ public IPointAnnotationManager CreatePointAnnotationManager( var clusterMaxZoom = clusterOptions != null ? new Java.Lang.Long((long)clusterOptions.ClusterMaxZoom) : null; + var options = new AnnotationSourceOptions( clusterMaxZoom, null, null, null, xclusterOptions); - var nativeManager = AnnotationPluginImplKt + var nativeManager = AnnotationsUtils .GetAnnotations(mapView) .CreateAnnotationManager( AnnotationType.PointAnnotation, @@ -79,7 +80,7 @@ public IPolylineAnnotationManager CreatePolylineAnnotationManager(string id, Lay if (mapView == null) return null; - var nativeManager = AnnotationPluginImplKt + var nativeManager = AnnotationsUtils .GetAnnotations(mapView) .CreateAnnotationManager( AnnotationType.PolylineAnnotation, diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Controller.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Controller.cs new file mode 100644 index 0000000..3a10dd4 --- /dev/null +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Controller.cs @@ -0,0 +1,31 @@ + +namespace MapboxMaui; + +partial class MapboxViewHandler : IMapboxController +{ + public CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions) + { + var mapView = mapboxFragment?.MapView; + + if (mapView == null) return null; + + var xcameraOptions = cameraOptions.ToNative(); + var xbounds = mapView.MapboxMap.CoordinateBoundsForCamera(xcameraOptions); + + return new CoordinateBounds( + xbounds.Southwest.ToMapPosition(), + xbounds.Northeast.ToMapPosition(), + xbounds.InfiniteBounds + ); + } + + public IPosition GetMapPosition(ScreenPosition position) + { + var mapView = mapboxFragment?.MapView; + + if (mapView == null) return null; + + var coords = mapView.MapboxMap.CoordinateForPixel(position.ToScreenCoordinate()); + return coords.ToMapPosition(); + } +} diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Query.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Query.cs index 2b3048f..e1ad4f6 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Query.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.Query.cs @@ -2,12 +2,12 @@ using Com.Mapbox.Bindgen; using Com.Mapbox.Maps; -using XQueriedFeature = Query.QueriedFeature; +using XQueriedFeature = Query.QueriedRenderedFeature; using XRenderedQueryOptions = Query.RenderedQueryOptions; partial class MapboxViewHandler : IMapFeatureQueryable { - public Task> QueryRenderedFeaturesWith(Point point, XRenderedQueryOptions options) + public Task> QueryRenderedFeaturesWith(ScreenPosition point, XRenderedQueryOptions options) { var mapView = PlatformView.GetMapView(); if (mapView == null) return Task.FromResult( @@ -15,14 +15,11 @@ public Task> QueryRenderedFeaturesWith(Point point, ); var tcs = new TaskCompletionSource>(); - var pixel = mapView.MapboxMap.PixelForCoordinate( - Com.Mapbox.Geojson.Point.FromLngLat(point.Y, point.X) - ); _ = mapView.MapboxMap.QueryRenderedFeatures( new RenderedQueryGeometry( new ScreenBox( - new ScreenCoordinate(pixel.GetX() - 25.0, pixel.GetY() - 25.0), - new ScreenCoordinate(pixel.GetX() + 25.0, pixel.GetY() + 25.0) + new ScreenCoordinate(point.X - 25.0, point.Y - 25.0), + new ScreenCoordinate(point.X + 25.0, point.Y + 25.0) ) ), options.ToPlatform(), @@ -32,7 +29,7 @@ public Task> QueryRenderedFeaturesWith(Point point, return tcs.Task; } - class QueryRenderedFeaturesWithPointCallback : Java.Lang.Object, IQueryFeaturesCallback + class QueryRenderedFeaturesWithPointCallback : Java.Lang.Object, IQueryRenderedFeaturesCallback { private readonly TaskCompletionSource> tcs; @@ -48,7 +45,7 @@ public void Run(Expected p0) return; } - var xfeatures = (p0.Value as Java.Util.IList)?.ToArray().Cast(); + var xfeatures = (p0.Value as Java.Util.IList)?.ToArray().Cast(); tcs.TrySetResult(xfeatures.Select(x => x.ToX()).ToArray()); } } diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs index c81a847..f6bbc50 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs @@ -1,265 +1,273 @@ - -using PlatformView = AndroidX.Fragment.App.FragmentContainerView; -using MapboxMapsStyle = Com.Mapbox.Maps.Style; -using Com.Mapbox.Maps; -using Com.Mapbox.Maps.Plugin.Scalebar; -using Microsoft.Maui.Platform; -using Android.Content; -using Android.Graphics; -using GeoJSON.Text; - -namespace MapboxMaui; -public partial class MapboxViewHandler -{ - MapboxFragment mapboxFragment; - - private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView == null) return; - - if (view.Light == null) return; - - mapView.MapboxMap.Style.SetStyleLight( - view.Light.ToPlatformValue(true) - ); - } - - private static void HandleLayersChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView == null) return; - - if (view.Layers == null) return; - - foreach (var layer in view.Layers) - { - var value = layer.ToPlatformValue(true); - - if (mapView.MapboxMap.Style.StyleLayerExists(layer.Id)) - { - mapView.MapboxMap.Style.SetStyleLayerProperties(layer.Id, value); - - continue; - } - - mapView.MapboxMap.Style.AddStyleLayer( - value, - layer.LayerPosition.ToPlatformValue() - ); - } - } - - private static void HandleImagesChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView == null) return; - - if (view.Images == null) return; - - foreach (var ximage in view.Images) - { - if (!string.IsNullOrWhiteSpace(ximage.Name)) - { - var resourceId = mapView.Resources.GetDrawableId(AppInfo.PackageName, ximage.Name); - - if (resourceId == 0) continue; - - var bitmap = BitmapFactory.DecodeResource(mapView.Resources, resourceId); - - mapView.MapboxMap.Style.AddImage( - ximage.Id, - bitmap, - ximage.Sdf); - } - - // TODO handle other image types - } - } - - private static void HandleTerrainChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView == null) return; - - if (view.Terrain == null) return; - - var platformValue = view.Terrain.ToPlatformValue(); - platformValue.BindTo(mapView.MapboxMap.Style); - } - - private static void HandleSourcesChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView == null) return; - - if (view.Sources == null) return; - var style = mapView.MapboxMap.Style; - - foreach (var source in view.Sources) - { - var sourceExists = style.StyleSourceExists(source.Id); - var platformValue = source.ToPlatformValue(); - - if (sourceExists) - { - style.SetStyleSourceProperties(source.Id, platformValue); - } - else - { - style.AddStyleSource(source.Id, platformValue); - } - - if (source is Styles.GeoJSONSource geojsonSource) - { - HandleGeoJSONSourceChanged(style, source.Id, geojsonSource.Data); - continue; - } - - if (!source.VolatileProperties.Any()) continue; - - var setStyleSourcePropertiesResult = mapView.MapboxMap.Style.SetStyleSourceProperties( - source.Id, - source.GetVolatileProperties() - ); - - if (setStyleSourcePropertiesResult.IsError) - { - System.Diagnostics.Debug.WriteLine(setStyleSourcePropertiesResult.Error); - } - } - } - - private static void HandleGeoJSONSourceChanged(MapboxMapsStyle style, string sourceId, IGeoJSONObject data) - { - var xdata = data switch - { - Styles.RawGeoJSONObject raw => GeoJSONSourceData.ValueOf(raw.Data), - GeoJSON.Text.Geometry.IGeometryObject geometry => GeoJSONSourceData.ValueOf(geometry.ToNative()), - _ => null, - }; - - if (xdata is null) return; - - var setStyleGeoJSONSourceDataResult = style.SetStyleGeoJSONSourceData(sourceId, xdata); - - if (setStyleGeoJSONSourceDataResult.IsError) - { - System.Diagnostics.Debug.WriteLine(setStyleGeoJSONSourceDataResult.Error); - } - } - - private static void HandleCameraOptionsChanged(MapboxViewHandler handler, IMapboxView view) - { - var cameraOptions = view.CameraOptions.ToNative(); - - handler.GetMapView()?.MapboxMap.SetCamera(cameraOptions); - } - - private static void HandleDebugOptionsChanged(MapboxViewHandler handler, IMapboxView view) - { - if (view.DebugOptions == null) return; - - var mapView = handler.GetMapView(); - if (mapView == null) return; - - var debugOptions = mapView.MapboxMap.Debug; - handler.GetMapView().MapboxMap.SetDebug(debugOptions, false); - - debugOptions = view.DebugOptions.ToNative(); - handler.GetMapView().MapboxMap.SetDebug(debugOptions, true); - } - - private static void HandleScaleBarVisibilityChanged(MapboxViewHandler handler, IMapboxView view) - { - var mapView = handler.GetMapView(); - if (mapView?.MapboxMap.Style?.IsStyleLoaded != true) return; - - var scaleBarPlugin = ScaleBarUtils.GetScaleBar(mapView); - if (view.ScaleBarVisibility == OrnamentVisibility.Hidden) - { - scaleBarPlugin.Enabled = false; - return; - } - - scaleBarPlugin.Enabled = true; - - } - - private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxView view) - { - var styleUri = view.MapboxStyle.ToNative(); - - if (string.IsNullOrWhiteSpace(styleUri)) - { - styleUri = MapboxMapsStyle.MapboxStreets; - } - - handler.GetMapView()?.MapboxMap.LoadStyleUri(styleUri); - } - - protected override PlatformView CreatePlatformView() - { - var mainActivity = (MauiAppCompatActivity)Context.GetActivity(); - - var fragmentContainerView = new PlatformView(Context) - { - Id = Android.Views.View.GenerateViewId(), - }; - mapboxFragment = new MapboxFragment(); - mapboxFragment.MapViewReady += HandleMapViewReady; - mapboxFragment.StyleLoaded += HandleStyleLoaded; - mapboxFragment.MapLoaded += HandleMapLoaded; - mapboxFragment.MapClicked += HandleMapClicked; - - var fragmentTransaction = mainActivity.SupportFragmentManager.BeginTransaction(); - fragmentTransaction.Replace(fragmentContainerView.Id, mapboxFragment, $"mapbox-maui-{fragmentContainerView.Id}"); - fragmentTransaction.CommitAllowingStateLoss(); - return fragmentContainerView; - } - - protected override void ConnectHandler(PlatformView platformView) - { - base.ConnectHandler(platformView); - - if (VirtualView is MapboxView mapboxView) - { - mapboxView.AnnotationController = this; - mapboxView.QueryManager = this; - } - } - - protected override void DisconnectHandler(PlatformView platformView) - { - if (mapboxFragment != null) - { - mapboxFragment.MapViewReady -= HandleMapViewReady; - mapboxFragment.StyleLoaded -= HandleStyleLoaded; - mapboxFragment.MapLoaded -= HandleMapLoaded; - mapboxFragment.MapClicked -= HandleMapClicked; - mapboxFragment.Dispose(); - mapboxFragment = null; - } - - if (VirtualView is MapboxView mapboxView) - { - mapboxView.AnnotationController = null; - mapboxView.QueryManager = null; - } - base.DisconnectHandler(platformView); - } - - private void HandleMapViewReady(MapView view) - => (VirtualView as MapboxView)?.InvokeMapReady(); - - private void HandleMapLoaded(MapView view) - => (VirtualView as MapboxView)?.InvokeMapLoaded(); - - private void HandleStyleLoaded(MapView view) - => (VirtualView as MapboxView)?.InvokeStyleLoaded(); - - private void HandleMapClicked(MapTappedPosition point) - => (VirtualView as MapboxView)?.InvokeMapTapped(point); - -} - + +using PlatformView = AndroidX.Fragment.App.FragmentContainerView; +using MapboxMapsStyle = Com.Mapbox.Maps.Style; +using Com.Mapbox.Maps; +using Com.Mapbox.Maps.Plugins.Scalebar; +using Microsoft.Maui.Platform; +using Android.Content; +using Android.Graphics; +using GeoJSON.Text; + +namespace MapboxMaui; +public partial class MapboxViewHandler +{ + MapboxFragment mapboxFragment; + + private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + if (view.Light == null) return; + + mapView.MapboxMap.Style.SetStyleLights( + view.Light.ToPlatformValue(true) + ); + } + + private static void HandleLayersChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + if (view.Layers == null) return; + + foreach (var layer in view.Layers) + { + var value = layer.ToPlatformValue(true); + + if (mapView.MapboxMap.Style.StyleLayerExists(layer.Id)) + { + mapView.MapboxMap.Style.SetStyleLayerProperties(layer.Id, value); + + continue; + } + + mapView.MapboxMap.Style.AddStyleLayer( + value, + layer.LayerPosition.ToPlatformValue() + ); + } + } + + private static void HandleImagesChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + if (view.Images == null) return; + + foreach (var ximage in view.Images) + { + if (!string.IsNullOrWhiteSpace(ximage.Name)) + { + var resourceId = mapView.Resources.GetDrawableId(AppInfo.PackageName, ximage.Name); + + if (resourceId == 0) continue; + + var bitmap = BitmapFactory.DecodeResource(mapView.Resources, resourceId); + + mapView.MapboxMap.Style.AddImage( + ximage.Id, + bitmap, + ximage.Sdf); + } + + // TODO handle other image types + } + } + + private static void HandleTerrainChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + if (view.Terrain == null) return; + + var platformValue = view.Terrain.ToPlatformValue(); + platformValue.BindTo(mapView.MapboxMap.Style); + } + + private static void HandleSourcesChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + if (view.Sources == null) return; + var style = mapView.MapboxMap.Style; + + foreach (var source in view.Sources) + { + var sourceExists = style.StyleSourceExists(source.Id); + var platformValue = source.ToPlatformValue(); + + if (sourceExists) + { + style.SetStyleSourceProperties(source.Id, platformValue); + } + else + { + style.AddStyleSource(source.Id, platformValue); + } + + if (source is Styles.GeoJSONSource geojsonSource) + { + HandleGeoJSONSourceChanged(style, source.Id, geojsonSource.Data); + continue; + } + + if (!source.VolatileProperties.Any()) continue; + + var setStyleSourcePropertiesResult = mapView.MapboxMap.Style.SetStyleSourceProperties( + source.Id, + source.GetVolatileProperties() + ); + + if (setStyleSourcePropertiesResult.IsError) + { + System.Diagnostics.Debug.WriteLine(setStyleSourcePropertiesResult.Error); + } + } + } + + private static void HandleGeoJSONSourceChanged(MapboxMapsStyle style, string sourceId, IGeoJSONObject data) + { + var xdata = data switch + { + Styles.RawGeoJSONObject raw => GeoJSONSourceData.ValueOf(raw.Data), + GeoJSON.Text.Geometry.IGeometryObject geometry => GeoJSONSourceData.ValueOf(geometry.ToNative()), + _ => null, + }; + + if (xdata is null) return; + + // TODO Correctly define dataID + var dataId = Guid.NewGuid().ToString(); + var setStyleGeoJSONSourceDataResult = style.SetStyleGeoJSONSourceData(sourceId, dataId, xdata); + + if (setStyleGeoJSONSourceDataResult.IsError) + { + System.Diagnostics.Debug.WriteLine(setStyleGeoJSONSourceDataResult.Error); + } + } + + private static void HandleCameraOptionsChanged(MapboxViewHandler handler, IMapboxView view) + { + var cameraOptions = view.CameraOptions.ToNative(); + + handler.GetMapView()?.MapboxMap.SetCamera(cameraOptions); + } + + private static void HandleDebugOptionsChanged(MapboxViewHandler handler, IMapboxView view) + { + if (view.DebugOptions == null) return; + + var mapView = handler.GetMapView(); + if (mapView == null) return; + + var debugOptions = mapView.MapboxMap.Debug; + handler.GetMapView().MapboxMap.SetDebug(debugOptions, false); + + debugOptions = view.DebugOptions.ToNative(); + handler.GetMapView().MapboxMap.SetDebug(debugOptions, true); + } + + private static void HandleScaleBarVisibilityChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView?.MapboxMap.Style?.IsStyleLoaded != true) return; + + var scaleBarPlugin = ScaleBarUtils.GetScaleBar(mapView); + if (view.ScaleBarVisibility == OrnamentVisibility.Hidden) + { + scaleBarPlugin.Enabled = false; + return; + } + + scaleBarPlugin.Enabled = true; + + } + + private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxView view) + { + var styleUri = view.MapboxStyle.ToNative(); + + if (string.IsNullOrWhiteSpace(styleUri)) + { + styleUri = MapboxMapsStyle.MapboxStreets; + } + + handler.GetMapView()?.MapboxMap.LoadStyleUri(styleUri); + } + + protected override PlatformView CreatePlatformView() + { + var mainActivity = (MauiAppCompatActivity)Context.GetActivity(); + + var fragmentContainerView = new PlatformView(Context) + { + Id = Android.Views.View.GenerateViewId(), + }; + mapboxFragment = new MapboxFragment(); + mapboxFragment.MapViewReady += HandleMapViewReady; + mapboxFragment.StyleLoaded += HandleStyleLoaded; + mapboxFragment.MapLoaded += HandleMapLoaded; + mapboxFragment.MapClicked += HandleMapClicked; + mapboxFragment.MapLongClicked += HandleMapLongClicked; + + var fragmentTransaction = mainActivity.SupportFragmentManager.BeginTransaction(); + fragmentTransaction.Replace(fragmentContainerView.Id, mapboxFragment, $"mapbox-maui-{fragmentContainerView.Id}"); + fragmentTransaction.CommitAllowingStateLoss(); + return fragmentContainerView; + } + + protected override void ConnectHandler(PlatformView platformView) + { + base.ConnectHandler(platformView); + + if (VirtualView is MapboxView mapboxView) + { + mapboxView.AnnotationController = this; + mapboxView.QueryManager = this; + mapboxView.MapboxController = this; + } + } + + protected override void DisconnectHandler(PlatformView platformView) + { + if (mapboxFragment != null) + { + mapboxFragment.MapViewReady -= HandleMapViewReady; + mapboxFragment.StyleLoaded -= HandleStyleLoaded; + mapboxFragment.MapLoaded -= HandleMapLoaded; + mapboxFragment.MapClicked -= HandleMapClicked; + mapboxFragment.MapLongClicked -= HandleMapLongClicked; + mapboxFragment.Dispose(); + mapboxFragment = null; + } + + if (VirtualView is MapboxView mapboxView) + { + mapboxView.AnnotationController = null; + mapboxView.QueryManager = null; + } + base.DisconnectHandler(platformView); + } + + private void HandleMapViewReady(MapView view) + => (VirtualView as MapboxView)?.InvokeMapReady(); + + private void HandleMapLoaded(MapView view) + => (VirtualView as MapboxView)?.InvokeMapLoaded(); + + private void HandleStyleLoaded(MapView view) + => (VirtualView as MapboxView)?.InvokeStyleLoaded(); + + private void HandleMapClicked(MapTappedPosition point) + => (VirtualView as MapboxView)?.InvokeMapTapped(point); + + private void HandleMapLongClicked(MapTappedPosition point) + => (VirtualView as MapboxView)?.InvokeMapLongTapped(point); + +} + diff --git a/src/libs/Mapbox.Maui/Platforms/Android/Offline/OfflineManager.cs b/src/libs/Mapbox.Maui/Platforms/Android/Offline/OfflineManager.cs index 8189ec0..372b8f7 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/Offline/OfflineManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/Offline/OfflineManager.cs @@ -7,7 +7,7 @@ public partial class OfflineManager: Java.Lang.Object { - IOfflineManagerInterface nativeManager; + Com.Mapbox.Maps.OfflineManager nativeManager; TileStore tileStore; partial void InitializePlatformManager() @@ -17,14 +17,7 @@ partial void InitializePlatformManager() TileStoreOptions.MAPBOX_ACCESS_TOKEN, Value.ValueOf(accessToken)); - var resourceOptions = new ResourceOptions.Builder() - .AccessToken(accessToken) - .TileStore(tileStore) - .Build(); - - nativeManager = new Com.Mapbox.Maps.OfflineManager( - resourceOptions - ); + nativeManager = new Com.Mapbox.Maps.OfflineManager(); } public bool IsMapboxStackConnected diff --git a/src/libs/Mapbox.Maui/Platforms/Android/QueriedFeatureExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/QueriedFeatureExtensions.cs index 8cce1ec..cd576d6 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/QueriedFeatureExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/QueriedFeatureExtensions.cs @@ -2,6 +2,7 @@ using Com.Mapbox.Maps; using XQueriedFeature = Query.QueriedFeature; +using XQueriedRenderedFeature = Query.QueriedRenderedFeature; public static class QueriedFeatureExtensions { @@ -11,8 +12,13 @@ public static XQueriedFeature ToX(this QueriedFeature src) Feature = src.Feature.ToX(), Source = src.Source, SourceLayer = src.SourceLayer, - // TODO Convert state - //State = src.State.ToX(), + State = src.State, + }; + public static XQueriedRenderedFeature ToX(this QueriedRenderedFeature src) + => new XQueriedRenderedFeature + { + QueriedFeature = src.QueriedFeature.ToX(), + Layers = src.Layers?.ToArray(), }; } diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs index c0ba41e..28ca899 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs @@ -11,6 +11,7 @@ namespace MapboxMaui; using MapboxMapsObjC; using Microsoft.Maui.Controls.Compatibility.Platform.iOS; using Microsoft.Maui.Platform; +using System.Runtime.InteropServices; public static partial class AdditionalExtensions { @@ -29,15 +30,15 @@ internal static TMBValue ToTMBValue(this PropertyValue propertyValue) if (propertyValue.Expression != null) { var nativeExpression = propertyValue.Expression.ToPlatformValue(); - return TMBValue.Expression(nativeExpression); + return TMBValue.FromExpression(nativeExpression); } if (propertyValue.Value is Color color) { - return TMBValue.Constant(color.ToPlatform()); + return TMBValue.FromConstant(color.ToPlatform()); } - return TMBValue.Constant(propertyValue.Value.Wrap()); + return TMBValue.FromConstant(propertyValue.Value.Wrap()); } internal static NSNumber[] ToPlatform(this double[] values, bool defaultToEmpty = false) @@ -81,7 +82,7 @@ internal static MBMStylePackLoadOptions ToNative(this StylePackLoadOptions optio ? NSNumber.FromInt32((int)options.Mode) : null, metadata, - options.AcceptsExpired + NSNumber.FromBoolean(options.AcceptsExpired) ); } @@ -94,10 +95,10 @@ this Terrain xvalue switch (xvalue.Exaggeration.Value) { case DslExpression expression: - result.Exaggeration = TMBValue.Expression(expression.ToPlatformValue()); + result.Exaggeration = TMBValue.FromExpression(expression.ToPlatformValue()); break; case double doubleValue: - result.Exaggeration = TMBValue.Constant(doubleValue.Wrap()); + result.Exaggeration = TMBValue.FromConstant(doubleValue.Wrap()); break; } @@ -263,41 +264,37 @@ public static IList ToNative(this IEnumerable o .ToList(); } - public static MBMCameraOptions ToNative(this CameraOptions cameraOptions) + public static TMBCameraOptions ToNative(this CameraOptions cameraOptions) { - var center = cameraOptions.Center.HasValue - ? new CLLocation(cameraOptions.Center.Value.X, cameraOptions.Center.Value.Y) - : null; - var padding = cameraOptions.Padding.HasValue - ? new MBMEdgeInsets( - cameraOptions.Padding.Value.Top, - cameraOptions.Padding.Value.Left, - cameraOptions.Padding.Value.Bottom, - cameraOptions.Padding.Value.Right) - : null; - var anchor = cameraOptions.Anchor.HasValue - ? new MBMScreenCoordinate( + CLLocationCoordinate2D center = cameraOptions.Center is not null + ? new CLLocationCoordinate2D( + cameraOptions.Center.Latitude, + cameraOptions.Center.Longitude) + : new CLLocationCoordinate2D(0, 0); + UIKit.UIEdgeInsets padding = cameraOptions.Padding.HasValue + ? new UIKit.UIEdgeInsets( + (float)cameraOptions.Padding.Value.Top, + (float)cameraOptions.Padding.Value.Left, + (float)cameraOptions.Padding.Value.Bottom, + (float)cameraOptions.Padding.Value.Right) + : UIKit.UIEdgeInsets.Zero; + var anchor = cameraOptions.Anchor is not null + ? new CoreGraphics.CGPoint( cameraOptions.Anchor.Value.X, cameraOptions.Anchor.Value.Y ) - : null; + : CoreGraphics.CGPoint.Empty; var zoom = cameraOptions.Zoom.HasValue - ? NSNumber.FromFloat(cameraOptions.Zoom.Value) - : null; + ? cameraOptions.Zoom.Value + : 14f; var bearing = cameraOptions.Bearing.HasValue - ? NSNumber.FromFloat(cameraOptions.Bearing.Value) - : null; + ? cameraOptions.Bearing.Value + : 0f; var pitch = cameraOptions.Pitch.HasValue - ? NSNumber.FromFloat(cameraOptions.Pitch.Value) - : null; - - if (center == null && - padding == null && - anchor == null && - zoom == null && - pitch == null) return null; + ? cameraOptions.Pitch.Value + : 0f; - return new MBMCameraOptions( + return new TMBCameraOptions( center, padding, anchor, diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationExtensions.cs index dbeb0d3..5da5b22 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationExtensions.cs @@ -10,20 +10,23 @@ public static class AnnotationExtensions internal static TMBPointAnnotation ToPlatformValue( this PointAnnotation xvalue) { - var result = TMBPointAnnotation.FromCoordinate( + var result = new TMBPointAnnotation( + xvalue.Id, new CLLocationCoordinate2D( xvalue.GeometryValue.Coordinates.Latitude, - xvalue.GeometryValue.Coordinates.Longitude)); + xvalue.GeometryValue.Coordinates.Longitude), + xvalue.IsSelected, + xvalue.IsDraggable); - result.IconAnchor = xvalue.IconAnchor?.AsNumber(); + result.IconAnchor = xvalue.IconAnchor?.ToPlatform(); result.IconImage = xvalue.IconImage; result.IconOffset = xvalue.IconOffset?.ToPlatform(); result.IconRotate = xvalue.IconRotate; result.IconSize = xvalue.IconSize; result.SymbolSortKey = xvalue.SymbolSortKey; - result.TextAnchor = xvalue.TextAnchor?.AsNumber(); + result.TextAnchor = xvalue.TextAnchor?.ToPlatform(); result.TextField = xvalue.TextField; - result.TextJustify = xvalue.TextJustify?.AsNumber(); + result.TextJustify = xvalue.TextJustify?.ToPlatform(); result.TextLetterSpacing = xvalue.TextLetterSpacing; result.TextLineHeight = xvalue.TextLineHeight; result.TextMaxWidth = xvalue.TextMaxWidth; @@ -31,7 +34,7 @@ internal static TMBPointAnnotation ToPlatformValue( result.TextRadialOffset = xvalue.TextRadialOffset; result.TextRotate = xvalue.TextRotate; result.TextSize = xvalue.TextSize; - result.TextTransform = xvalue.TextTransform?.AsNumber(); + result.TextTransform = xvalue.TextTransform?.ToPlatform(); result.IconColor = xvalue.IconColor?.ToPlatform(); result.IconHaloBlur = xvalue.IconHaloBlur; result.IconHaloColor = xvalue.IconHaloColor?.ToPlatform(); @@ -49,10 +52,13 @@ internal static TMBPointAnnotation ToPlatformValue( internal static TMBCircleAnnotation ToPlatformValue( this CircleAnnotation xvalue) { - var result = TMBCircleAnnotation.FromCenter( + var result = new TMBCircleAnnotation( + xvalue.Id, new CLLocationCoordinate2D( xvalue.GeometryValue.Coordinates.Latitude, - xvalue.GeometryValue.Coordinates.Longitude)); + xvalue.GeometryValue.Coordinates.Longitude), + xvalue.IsSelected, + xvalue.IsDraggable); result.CircleBlur = xvalue.CircleBlur; result.CircleColor = xvalue.CircleColor?.ToPlatform(); @@ -85,12 +91,8 @@ this PolygonAnnotation xvalue ) ).ToArray() ); - var polygon = TMBPolygon.FromCoordinates( - coordinates - ); - var result = TMBPolygonAnnotation.Polygon( - polygon - ); + var polygon = new TMBPolygon(coordinates); + var result = new TMBPolygonAnnotation(xvalue.Id, polygon, false, false); result.FillColor = xvalue.FillColor?.ToPlatform(); result.FillOpacity = xvalue.FillOpacity.HasValue ? NSNumber.FromDouble(xvalue.FillOpacity.Value) @@ -117,7 +119,7 @@ this PolylineAnnotation xvalue ) .Cast() .ToArray(); - var result = TMBPolylineAnnotation.FromId( + var result = new TMBPolylineAnnotation( xvalue.Id, coordinates, xvalue.IsSelected, @@ -127,7 +129,7 @@ this PolylineAnnotation xvalue result.LineBlur = xvalue.LineBlur.ToPlatform(); result.LineColor = xvalue.LineColor.ToPlatform(); result.LineGapWidth = xvalue.LineGapWidth.ToPlatform(); - result.LineJoin = xvalue.LineJoin?.AsNumber(); + result.LineJoin = xvalue.LineJoin?.ToPlatform(); result.LineOffset = xvalue.LineOffset.ToPlatform(); result.LineOpacity = xvalue.LineOpacity.ToPlatform(); result.LinePattern = xvalue.LinePattern; diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationManager.cs index a5821d0..e9134f2 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/AnnotationManager.cs @@ -26,7 +26,7 @@ protected AnnotationManager(string id, ITMBAnnotationManager nativeManager) public event EventHandler AnnotationsSelected; - public void DidDetectTappedAnnotations(ITMBAnnotationManager manager, NSArray annotations) + public void DidDetectTappedAnnotations(ITMBAnnotationManager manager, NSObject[] annotations) { if (AnnotationsSelected == null) return; diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/CircleAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/CircleAnnotationManager.cs index 1b20cd9..649fb8f 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/CircleAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/CircleAnnotationManager.cs @@ -18,18 +18,17 @@ TMBCircleAnnotationManager nativeManager : base(id, nativeManager) { this.nativeManager = nativeManager; - nativeManager.Delegate = this; } public CirclePitchAlignment? CirclePitchAlignment { - get => nativeManager.CirclePitchAlignment?.CirclePitchAlignmentX(); - set => nativeManager.CirclePitchAlignment = value?.AsNumber(); + get => nativeManager.CirclePitchAlignment?.RawValue; + set => nativeManager.CirclePitchAlignment = value?.ToPlatform(); } public CirclePitchScale? CirclePitchScale { - get => nativeManager.CirclePitchScale?.StringValue; - set => nativeManager.CirclePitchScale = value?.AsNumber(); + get => nativeManager.CirclePitchScale?.RawValue; + set => nativeManager.CirclePitchScale = value?.ToPlatform(); } public double[] CircleTranslate { @@ -42,8 +41,8 @@ public double[] CircleTranslate } public CircleTranslateAnchor? CircleTranslateAnchor { - get => nativeManager.CircleTranslateAnchor?.StringValue; - set => nativeManager.CircleTranslateAnchor = value?.AsNumber(); + get => nativeManager.CircleTranslateAnchor?.RawValue; + set => nativeManager.CircleTranslateAnchor = value?.ToPlatform(); } public override void AddAnnotations(params CircleAnnotation[] xitems) diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PointAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PointAnnotationManager.cs index 5334afa..1da7db8 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PointAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PointAnnotationManager.cs @@ -17,7 +17,6 @@ TMBPointAnnotationManager nativeManager : base(id, nativeManager) { this.nativeManager = nativeManager; - nativeManager.Delegate = this; } public bool? IconAllowOverlap @@ -47,27 +46,13 @@ public double? IconPadding } public IconPitchAlignment? IconPitchAlignment { - get => nativeManager.IconPitchAlignment?.IconPitchAlignmentX(); - set => nativeManager.IconPitchAlignment = value?.AsNumber(); + get => nativeManager.IconPitchAlignment?.RawValue; + set => nativeManager.IconPitchAlignment = value?.ToPlatform(); } public IconRotationAlignment? IconRotationAlignment { - get => nativeManager.IconRotationAlignment?.IconRotationAlignmentX(); - set => nativeManager.IconRotationAlignment = value?.AsNumber(); - } - public IconTextFit? IconTextFit - { - get => nativeManager.IconTextFit?.IconTextFitX(); - set => nativeManager.IconTextFit = value?.AsNumber(); - } - public double[] IconTextFitPadding - { - get => nativeManager.IconTextFitPadding? - .Select(x => x.DoubleValue) - .ToArray() ?? Array.Empty(); - set => nativeManager.IconTextFitPadding = value? - .Select(NSNumber.FromDouble) - .ToArray(); + get => nativeManager.IconRotationAlignment?.RawValue; + set => nativeManager.IconRotationAlignment = value?.ToPlatform(); } public bool? SymbolAvoidEdges { @@ -76,8 +61,8 @@ public bool? SymbolAvoidEdges } public SymbolPlacement? SymbolPlacement { - get => nativeManager.SymbolPlacement?.SymbolPlacementX(); - set => nativeManager.SymbolPlacement = value?.AsNumber(); + get => nativeManager.SymbolPlacement?.RawValue; + set => nativeManager.SymbolPlacement = value?.ToPlatform(); } public double? SymbolSpacing { @@ -86,8 +71,8 @@ public double? SymbolSpacing } public SymbolZOrder? SymbolZOrder { - get => nativeManager.SymbolZOrder?.SymbolZOrderX(); - set => nativeManager.SymbolZOrder = value?.AsNumber(); + get => nativeManager.SymbolZOrder?.RawValue; + set => nativeManager.SymbolZOrder = value?.ToPlatform(); } public bool? TextAllowOverlap { @@ -126,30 +111,30 @@ public double? TextPadding } public TextPitchAlignment? TextPitchAlignment { - get => nativeManager.TextPitchAlignment?.TextPitchAlignmentX(); - set => nativeManager.TextPitchAlignment = value?.AsNumber(); + get => nativeManager.TextPitchAlignment?.RawValue; + set => nativeManager.TextPitchAlignment = value?.ToPlatform(); } public TextRotationAlignment? TextRotationAlignment { - get => nativeManager.TextRotationAlignment?.StringValue; - set => nativeManager.TextRotationAlignment = value?.AsNumber(); + get => nativeManager.TextRotationAlignment?.RawValue; + set => nativeManager.TextRotationAlignment = value?.ToPlatform(); } public TextAnchor[] TextVariableAnchor { get => nativeManager.TextVariableAnchor? - .Select(x => (TextAnchor)x.TextAnchorX()) + .Select(x => (TextAnchor)x.RawValue) .ToArray() ?? Array.Empty(); set => nativeManager.TextVariableAnchor = value? - .Select(x => x.AsNumber()) + .Select(x => x.ToPlatform()) .ToArray(); } public TextWritingMode[] TextWritingMode { get => nativeManager.TextWritingMode? - .Select(x => (TextWritingMode)x.TextWritingModeX()) + .Select(x => (TextWritingMode)x.RawValue) .ToArray() ?? Array.Empty(); set => nativeManager.TextWritingMode = value? - .Select(x => x.AsNumber()) + .Select(x => x.ToPlatform()) .ToArray(); } public double[] IconTranslate @@ -163,8 +148,8 @@ public double[] IconTranslate } public IconTranslateAnchor? IconTranslateAnchor { - get => nativeManager.IconTranslateAnchor?.IconTranslateAnchorX(); - set => nativeManager.IconTranslateAnchor = value?.AsNumber(); + get => nativeManager.IconTranslateAnchor?.RawValue; + set => nativeManager.IconTranslateAnchor = value?.ToPlatform(); } public double[] TextTranslate { @@ -177,13 +162,8 @@ public double[] TextTranslate } public TextTranslateAnchor? TextTranslateAnchor { - get => nativeManager.TextTranslateAnchor?.TextTranslateAnchorX(); - set => nativeManager.TextTranslateAnchor = value?.AsNumber(); - } - public double? TextLineHeight - { - get => nativeManager.TextLineHeight?.DoubleValue; - set => nativeManager.TextLineHeight = value; + get => nativeManager.TextTranslateAnchor?.RawValue; + set => nativeManager.TextTranslateAnchor = value?.ToPlatform(); } public override void AddAnnotations(params PointAnnotation[] xitems) diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolygonAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolygonAnnotationManager.cs index 32fda7b..fbef8c7 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolygonAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolygonAnnotationManager.cs @@ -17,7 +17,6 @@ TMBPolygonAnnotationManager nativeManager : base(id, nativeManager) { this.nativeManager = nativeManager; - nativeManager.Delegate = this; } public bool? FillAntialias @@ -32,8 +31,8 @@ public double[] FillTranslate } public FillTranslateAnchor? FillTranslateAnchor { - get => nativeManager.FillTranslateAnchor?.FillTranslateAnchorX(); - set => nativeManager.FillTranslateAnchor = value?.AsNumber(); + get => nativeManager.FillTranslateAnchor?.RawValue; + set => nativeManager.FillTranslateAnchor = value?.ToPlatform(); } public override void AddAnnotations(params PolygonAnnotation[] xitems) diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolylineAnnotationManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolylineAnnotationManager.cs index d93e46c..43e1f35 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolylineAnnotationManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Annotations/PolylineAnnotationManager.cs @@ -17,13 +17,12 @@ TMBPolylineAnnotationManager nativeManager : base(id, nativeManager) { this.nativeManager = nativeManager; - nativeManager.Delegate = this; } public LineCap? LineCap { - get => nativeManager.LineCap?.LineCapX(); - set => nativeManager.LineCap = value?.AsNumber(); + get => nativeManager.LineCap?.RawValue; + set => nativeManager.LineCap = value?.ToPlatform(); } public double? LineMiterLimit { @@ -47,8 +46,8 @@ public double[] LineTranslate } public LineTranslateAnchor? LineTranslateAnchor { - get => nativeManager.LineTranslateAnchor?.LineTranslateAnchorX(); - set => nativeManager.LineTranslateAnchor = value?.AsNumber(); + get => nativeManager.LineTranslateAnchor?.RawValue; + set => nativeManager.LineTranslateAnchor = value?.ToPlatform(); } public double[] LineTrimOffset { diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs index f354af5..7d64a4a 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs @@ -1,7 +1,6 @@ using CoreGraphics; +using CoreLocation; using Foundation; -using GeoJSON.Text.Feature; -using GeoJSON.Text.Geometry; using MapboxCommon; using MapboxMapsObjC; @@ -9,6 +8,19 @@ namespace MapboxMaui; public static class GeometryExtensions { + internal static MapTappedPosition ToMapTappedPosition(this CLLocationCoordinate2D coords, CGPoint screenCoordinate) + { + return new MapTappedPosition( + new ScreenPosition( + screenCoordinate.X, + screenCoordinate.Y + ), + new MapPosition( + coords.Latitude, + coords.Longitude + )); + } + internal static MBXGeometry ToNative(this IGeometryObject xobj) { switch (xobj) @@ -81,6 +93,21 @@ internal static CGPoint ToCGPoint(this IPosition xobj) ); } + internal static CGPoint ToCGPoint(this ScreenPosition xobj) + { + return new CGPoint( + xobj.X, + xobj.Y + ); + } + + public static IPosition ToMapPosition(this CLLocationCoordinate2D point) + { + return new MapPosition( + point.Latitude, + point.Longitude); + } + internal static NSValue ToNSValue(this IPosition xobj) { return NSValue.FromCGPoint( @@ -89,14 +116,15 @@ internal static NSValue ToNSValue(this IPosition xobj) } internal static IPosition ToPosition(this NSValue src) - => new Position( + => new MapPosition( src.CoordinateValue.Latitude, src.CoordinateValue.Longitude ); internal static IGeometryObject ToX(this MBXGeometry src) { - switch (src.GeometryType) { + switch (src.GeometryType) + { case MBXGeometryType.Point: var pointPosition = src .ExtractLocations() @@ -118,7 +146,7 @@ internal static IGeometryObject ToX(this MBXGeometry src) .Select( z => z .Cast() - .Select( + .Select( y => new[] { y.CoordinateValue.Longitude, y.CoordinateValue.Latitude @@ -188,9 +216,13 @@ internal static Feature ToX(this MBXFeature src) { var geometry = src.Geometry.ToX(); - var properties = new Dictionary(); - // TODO Convert to C# obj - // properties = src.Properties; + var kvPairs = src.Properties + .Keys + .Select(x => new KeyValuePair( + x.ToString(), + src.Properties[x]) + ); + var properties = new Dictionary(kvPairs); return new Feature(geometry, properties, src.Identifier?.ToString()); } diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapViewContainer.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapViewContainer.cs index 68cb433..2ca1c2e 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/MapViewContainer.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapViewContainer.cs @@ -1,6 +1,6 @@ -using MapboxCoreMaps; -using MapboxMaps; -using MapboxMapsObjC; +using MapboxCoreMaps; +using MapboxMaps; +using MapboxMapsObjC; using UIKit; namespace MapboxMaui; @@ -12,9 +12,14 @@ public class MapViewContainer : UIView public MapViewContainer(string accessToken) : base() { - var resourceOptions = new MBMResourceOptions(accessToken, null, null, null, null); + if (!string.IsNullOrWhiteSpace(accessToken)) + { + MapboxCommon.MBXMapboxOptions.SetAccessTokenForToken(accessToken); + } + + var mapboxOptions = new MBMMapOptions(null, null, null, null, null, null, 1, null); var options = MapInitOptionsFactory - .CreateWithResourceOptions(resourceOptions, null, null, null, null); + .CreateWithMapOptions(mapboxOptions, null, null, null, 0); var mapView = MapViewFactory.CreateWithFrame( CoreGraphics.CGRect.FromLTRB(0, 0, 320, 675), diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs new file mode 100644 index 0000000..1a73146 --- /dev/null +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs @@ -0,0 +1,34 @@ +using MapboxMapsObjC; + +namespace MapboxMaui; + +partial class MapboxViewHandler : IMapboxController +{ + public CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions) + { + var mapView = PlatformView.MapView; + + if (mapView == null) return null; + + var xcameraOptions = cameraOptions.ToNative(); + var xbounds = mapView.MapboxMap().CoordinateBoundsForCameraBounds(xcameraOptions); + + return new CoordinateBounds( + xbounds.Southeast.ToMapPosition(), + xbounds.Northeast.ToMapPosition(), + xbounds.InfiniteBounds + ); + } + public IPosition GetMapPosition(ScreenPosition position) + { + var mapView = PlatformView.MapView; + + if (mapView == null) return null; + + var coords = mapView.MapboxMap().CoordinateFor( + position.ToCGPoint() + ); + + return coords.ToMapPosition(); + } +} diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Query.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Query.cs index 6ba8e77..91a04de 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Query.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Query.cs @@ -3,24 +3,26 @@ using MapboxMaui.Query; using MapboxMapsObjC; using Foundation; +using CoreGraphics; partial class MapboxViewHandler : IMapFeatureQueryable { - public Task> QueryRenderedFeaturesWith(Point point, RenderedQueryOptions options) + public Task> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options) { var mapView = PlatformView.MapView; if (mapView == null) return Task.FromResult( - Array.Empty() as IEnumerable + Array.Empty() as IEnumerable ); - var tcs = new TaskCompletionSource>(); + var tcs = new TaskCompletionSource>(); - _ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(point, options.ToPlatform(), (features, error) => { + var xpoint = new CGPoint(point.X, point.Y); + _ = mapView.MapboxMap().QueryRenderedFeaturesWithPoint(xpoint, options.ToPlatform(), (features, error) => { if (error != null) { tcs.TrySetException(new NSErrorException(error)); return; } - var xfeatures = features + var xfeatures = features.ToArray() .Select(x => x.ToX()) .ToArray(); diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs index ba05771..bda3e55 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs @@ -1,4 +1,6 @@  +using MapboxCommon; + namespace MapboxMaui; using Foundation; @@ -10,6 +12,7 @@ namespace MapboxMaui; public partial class MapboxViewHandler { UITapGestureRecognizer mapTapGestureRecognizer; + UILongPressGestureRecognizer mapLongPressGestureRecognizer; private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView view) { @@ -20,15 +23,18 @@ private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView vi if (light == null) return; var platformProperties = light.Properties.Wrap() as NSDictionary; - var style = mapView.MapboxMap().Style; - style.SetLightWithProperties( - platformProperties, - (error) => - { - if (error == null) return; - - System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); - }); + var style = mapView.MapboxMap(); + + // TODO SetLightWithProperties + throw new NotImplementedException(); + //style.SetLightWithProperties( + // platformProperties, + // (error) => + // { + // if (error == null) return; + + // System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); + // }); } private static void HandleImagesChanged(MapboxViewHandler handler, IMapboxView view) @@ -39,7 +45,7 @@ private static void HandleImagesChanged(MapboxViewHandler handler, IMapboxView v var images = view.Images; if (images == null) return; - var style = mapView.MapboxMap().Style; + var style = mapView.MapboxMap(); foreach (var ximage in images) { @@ -79,7 +85,7 @@ private static void HandleLayersChanged(MapboxViewHandler handler, IMapboxView v var layers = view.Layers; if (layers == null) return; - var style = mapView.MapboxMap().Style; + var style = mapView.MapboxMap(); foreach (var layer in layers) { @@ -101,7 +107,7 @@ private static void HandleLayersChanged(MapboxViewHandler handler, IMapboxView v continue; } - style.AddLayerWithProperties( + style.AddLayerWith( properties, layerPosition, (error) => @@ -124,7 +130,7 @@ private static void HandleTerrainChanged(MapboxViewHandler handler, IMapboxView var platformValue = terrain.ToPlatformValue(); - mapView.MapboxMap().Style.SetTerrain(platformValue, null); + mapView.MapboxMap().SetTerrain(platformValue, null); } private static void HandleSourcesChanged(MapboxViewHandler handler, IMapboxView view) @@ -135,7 +141,7 @@ private static void HandleSourcesChanged(MapboxViewHandler handler, IMapboxView var sources = view.Sources; if (sources == null) return; - var style = mapView.MapboxMap().Style; + var style = mapView.MapboxMap(); foreach (var source in sources) { @@ -173,54 +179,47 @@ private static void HandleSourcesChanged(MapboxViewHandler handler, IMapboxView } } - private static void HandleGeoJSONSource(TMBStyle style, string sourceId, NSDictionary platformValue, GeoJSON.Text.IGeoJSONObject data) + private static void HandleGeoJSONSource(TMBMapboxMap style, string sourceId, NSDictionary platformValue, GeoJSON.Text.IGeoJSONObject data) { var sourceExists = style.SourceExistsWithId(sourceId); - switch(data) { + switch (data) + { case RawGeoJSONObject raw: + + var sourceData = TMBGeoJSONSourceData.FromString(raw.Data); + if (sourceExists) { - style.UpdateGeoJSONSourceWithId( - sourceId, raw.Data, - (error) => - { - if (error == null) return; - - System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); - }); + style.UpdateGeoJSONSourceWithId(sourceId, sourceData, null); return; } + + var source = new TMBGeoJSONSource(sourceId); + source.Data = sourceData; + + style.AddSource(source , sourceId, (error) => + { + if (error == null) return; + System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); + }); + break; + + case GeoJSON.Text.Geometry.IGeometryObject geometry: - style.AddGeoJSONSourceWithId( - sourceId, platformValue, raw.Data, - (error) => - { - if (error == null) return; + var feature = new MBXFeature(new NSString(sourceId), geometry.ToNative(), platformValue); - System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); - }); - break; - case GeoJSON.Text.Geometry.IGeometryObject geometry: if (sourceExists) { - style.UpdateGeoJSONSourceWithId( - sourceId, geometry.ToNative(), - (error) => { - if (error == null) return; - - System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); - }); + style.UpdateGeoJSONSourceFeaturesForSourceId( + sourceId, [feature], null); return; } - style.AddSourceWithId( - sourceId, geometry.ToNative(), - (error) => { - if (error == null) return; - - System.Diagnostics.Debug.WriteLine(error.LocalizedDescription); - }); + + style.AddGeoJSONSourceFeaturesForSourceId( + sourceId, [feature], null); + break; - } + } } private static void HandleCameraOptionsChanged(MapboxViewHandler handler, IMapboxView view) @@ -266,7 +265,7 @@ private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxV var styleUri = view.MapboxStyle.ToNative(); if (string.IsNullOrWhiteSpace(styleUri)) return; - mapView.MapboxMap().LoadStyleURI(styleUri, (style, error) => + mapView.MapboxMap().LoadStyleWithUri(styleUri, null, (error) => { if (error == null) return; @@ -276,11 +275,7 @@ private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxV protected override PlatformView CreatePlatformView() { - var accessToken = string.IsNullOrWhiteSpace(ACCESS_TOKEN) - ? TMBResourceOptionsManager.Default.ResourceOptions.AccessToken - : ACCESS_TOKEN; - - return new PlatformView(accessToken); + return new PlatformView(ACCESS_TOKEN); } protected override void DisconnectHandler(PlatformView platformView) @@ -291,6 +286,7 @@ protected override void DisconnectHandler(PlatformView platformView) { mapboxView.AnnotationController = null; mapboxView.QueryManager = null; + mapboxView.MapboxController = null; } var mapView = platformView.MapView; @@ -300,6 +296,11 @@ protected override void DisconnectHandler(PlatformView platformView) { mapView.RemoveGestureRecognizer(mapTapGestureRecognizer); } + + if (mapLongPressGestureRecognizer != null) + { + mapView.RemoveGestureRecognizer(mapLongPressGestureRecognizer); + } } protected override void ConnectHandler(PlatformView platformView) @@ -311,6 +312,7 @@ protected override void ConnectHandler(PlatformView platformView) mapboxView.InvokeMapReady(); mapboxView.AnnotationController = this; mapboxView.QueryManager = this; + mapboxView.MapboxController = this; } var mapView = platformView.MapView; @@ -329,32 +331,43 @@ protected override void ConnectHandler(PlatformView platformView) mapTapGestureRecognizer = new UITapGestureRecognizer(HandleMapTapped); mapView.AddGestureRecognizer(mapTapGestureRecognizer); + + mapLongPressGestureRecognizer = new UILongPressGestureRecognizer(HandleMapLongPress); + mapView.AddGestureRecognizer(mapLongPressGestureRecognizer); + } + + private void HandleMapLongPress(UILongPressGestureRecognizer longPressGestureRecognizer) + { + if (longPressGestureRecognizer.State != UIGestureRecognizerState.Began) return; + + var position = GetPositionForGesture(longPressGestureRecognizer); + if (position == null) return; + + (VirtualView as MapboxView)?.InvokeMapLongTapped( + position + ); } private void HandleMapTapped(UITapGestureRecognizer tapGestureRecognizer) { - var mapView = this.PlatformView.MapView; - if (mapView == null) return; - var screenPosition = tapGestureRecognizer.LocationInView(mapView); + var position = GetPositionForGesture(tapGestureRecognizer); + if (position == null) return; + + (VirtualView as MapboxView)?.InvokeMapTapped( + position + ); + } + + private MapTappedPosition GetPositionForGesture(UIGestureRecognizer gesture) + { + var mapView = PlatformView.MapView; + if (mapView == null) return null; + + var screenPosition = gesture.LocationInView(mapView); var coords = mapView.MapboxMap().CoordinateFor( screenPosition ); - var mapTappedPosition = new MapTappedPosition - { - ScreenPosition = new Point( - screenPosition.X, - screenPosition.Y - ), - Point = new GeoJSON.Text.Geometry.Point( - new GeoJSON.Text.Geometry.Position( - coords.Latitude, - coords.Longitude - ) - ), - }; - (VirtualView as MapboxView)?.InvokeMapTapped( - mapTappedPosition - ); + return coords.ToMapTappedPosition(screenPosition); } } \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/Offline/OfflineManager.cs b/src/libs/Mapbox.Maui/Platforms/iOS/Offline/OfflineManager.cs index 92c1b5b..3edba7e 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/Offline/OfflineManager.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/Offline/OfflineManager.cs @@ -1,190 +1,179 @@ using Foundation; -using MapboxCommon; -using MapboxCoreMaps; -using MapboxMapsObjC; - -namespace MapboxMaui.Offline; - -using PlatformOfflineManager = MBMOfflineManager; - -partial class OfflineManager : NSObject, IOfflineManager -{ - PlatformOfflineManager nativeManager; - MBXTileStore titleStore; - - partial void InitializePlatformManager() - { - var resourceOptions = new MBMResourceOptions(accessToken, null, null, null, null); - var options = MapInitOptionsFactory.CreateWithResourceOptions( - resourceOptions, - null, - cameraOptions.ToNative(), - null, - null); - - nativeManager = new PlatformOfflineManager( - options.ResourceOptions() - ); - - titleStore = MBXTileStore.Create(); - titleStore.SetOptionForKey( - MBXTileStoreOptions.MapboxAccessToken, - new NSString(accessToken)); - } - - public bool IsMapboxStackConnected - { - get => MBXOfflineSwitch.Instance.IsMapboxStackConnected; - set => MBXOfflineSwitch.Instance.SetMapboxStackConnectedForConnected(value); - } - - public void DownloadStyle( - string styleUri, - StylePackLoadOptions options, - Action progressHandler, - Action completionHandler) - { - var nativeOptions = options.ToNative(); - - nativeManager.LoadStyleWithStyleUriString( - styleUri, - nativeOptions, - (progress) => - { - var xprogress = new StylePackLoadProgress - { - CompletedResourceCount = progress.CompletedResourceCount, - CompletedResourceSize = progress.CompletedResourceSize, - ErroredResourceCount = progress.ErroredResourceCount, - LoadedResourceCount = progress.LoadedResourceCount, - LoadedResourceSize = progress.LoadedResourceSize, - RequiredResourceCount = progress.RequiredResourceCount, - }; - - progressHandler?.Invoke(xprogress); - }, - (stylePack, error) => - { - var xstylePack = stylePack != null - ? new StylePack - { - CompletedResourceCount = stylePack.CompletedResourceCount, - CompletedResourceSize = stylePack.CompletedResourceSize, - Expires = stylePack.Expires != null - ? DateTime.Parse(stylePack.Expires.ToString()) - : null, - RequiredResourceCount = stylePack.RequiredResourceCount, - StyleUri = stylePack.StyleURI, - GlyphsRasterizationMode = (GlyphsRasterizationMode)stylePack.GlyphsRasterizationMode, - } - : null; - var xerror = error != null - ? new NSErrorException(error) - : null; - - completionHandler?.Invoke(xstylePack, xerror); - }); - } - - - public void DownloadTile( - string tileId, - TileRegionLoadOptions xoptions, - Action progressHandler, - Action completionHandler) - { - if (xoptions == null) return; - - var descriptors = xoptions.TilesetDescriptors? - .Select( - x => new MBMTilesetDescriptorOptions( - x.StyleUri, - (byte)x.MinZoom, - (byte)x.MaxZoom, - x.StylePackLoadOptions?.ToNative() - )) - .Select( - nativeManager.CreateTilesetDescriptorForTilesetDescriptorOptions) - .ToArray(); - - var metadata = new NSMutableDictionary(); - if (xoptions.Metadata != null) - { - foreach (var item in xoptions.Metadata) - { - metadata[new NSString(item.Key)] = item.Value.Wrap(); - } - } - - var options = new MBXTileRegionLoadOptions( - xoptions.Geometry?.ToNative(), - descriptors, - metadata, - xoptions.AcceptsExpired, - (MBXNetworkRestriction)xoptions.NetworkRestriction, - xoptions.StartLocation.HasValue - ? new CoreLocation.CLLocation( - xoptions.StartLocation.Value.X, - xoptions.StartLocation.Value.Y - ) - : null, - xoptions.AvarageBytesPerSecond.HasValue - ? NSNumber.FromInt32(xoptions.AvarageBytesPerSecond.Value) - : null, - xoptions.ExtraOptions?.Wrap() - ); - - titleStore.LoadTileRegionForId( - tileId, - options, - (progress) => - { - var xprogress = new TileRegionLoadProgress - { - CompletedResourceCount = progress.CompletedResourceCount, - CompletedResourceSize = progress.CompletedResourceSize, - ErroredResourceCount = progress.ErroredResourceCount, - LoadedResourceCount = progress.LoadedResourceCount, - LoadedResourceSize = progress.LoadedResourceSize, +using MapboxCommon; +using MapboxCoreMaps; +using MapboxMapsObjC; + +namespace MapboxMaui.Offline; + +using PlatformOfflineManager = MBMOfflineManager; + +partial class OfflineManager : NSObject, IOfflineManager +{ + PlatformOfflineManager nativeManager; + MBXTileStore titleStore; + + partial void InitializePlatformManager() + { + nativeManager = new PlatformOfflineManager(); + nativeManager = new PlatformOfflineManager(); + + titleStore = MBXTileStore.Create(); + } + + public bool IsMapboxStackConnected + { + get => MBXOfflineSwitch.Instance.IsMapboxStackConnected; + set => MBXOfflineSwitch.Instance.SetMapboxStackConnectedForConnected(value); + } + + public void DownloadStyle( + string styleUri, + StylePackLoadOptions options, + Action progressHandler, + Action completionHandler) + { + var nativeOptions = options.ToNative(); + + nativeManager.LoadStylePackFor( + styleUri, + nativeOptions, + (progress) => + { + var xprogress = new StylePackLoadProgress + { + CompletedResourceCount = progress.CompletedResourceCount, + CompletedResourceSize = progress.CompletedResourceSize, + ErroredResourceCount = progress.ErroredResourceCount, + LoadedResourceCount = progress.LoadedResourceCount, + LoadedResourceSize = progress.LoadedResourceSize, RequiredResourceCount = progress.RequiredResourceCount, - }; - - progressHandler?.Invoke(xprogress); - }, - (tileRegion, error) => - { - var xtileRegion = tileRegion != null - ? new TileRegion - { - CompletedResourceCount = tileRegion.CompletedResourceCount, - CompletedResourceSize = tileRegion.CompletedResourceSize, - Expires = tileRegion.Expires != null - ? DateTime.Parse(tileRegion.Expires.ToString()) - : null, - RequiredResourceCount = tileRegion.RequiredResourceCount, - Id = tileRegion.Id, - } - : null; - var xerror = error != null - ? new NSErrorException(error) - : null; - - completionHandler?.Invoke(xtileRegion, xerror); + }; + progressHandler?.Invoke(xprogress); + }, + (stylePack, error) => + { + var xstylePack = stylePack != null + ? new StylePack + { + CompletedResourceCount = stylePack.CompletedResourceCount, + CompletedResourceSize = stylePack.CompletedResourceSize, + Expires = stylePack.Expires != null + ? DateTime.Parse(stylePack.Expires.ToString()) + : null, + RequiredResourceCount = stylePack.RequiredResourceCount, + StyleUri = stylePack.StyleURI, + GlyphsRasterizationMode = (GlyphsRasterizationMode)stylePack.GlyphsRasterizationMode, + } + : null; + var xerror = error != null + ? new NSErrorException(error) + : null; + completionHandler?.Invoke(xstylePack, xerror); + }); + } + + + public void DownloadTile( + string tileId, + TileRegionLoadOptions xoptions, + Action progressHandler, + Action completionHandler) + { + if (xoptions == null) return; + + var descriptors = xoptions.TilesetDescriptors? + .Select( + x => new MBMTilesetDescriptorOptions( + x.StyleUri, + (byte)x.MinZoom, + (byte)x.MaxZoom, + null, + x.StylePackLoadOptions?.ToNative(), + null + )) + .Select( + nativeManager.CreateTilesetDescriptorForTilesetDescriptorOptions) + .ToArray(); + + var metadata = new NSMutableDictionary(); + if (xoptions.Metadata != null) + { + foreach (var item in xoptions.Metadata) + { + metadata[new NSString(item.Key)] = item.Value.Wrap(); } - ); - } - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - - if (disposing) - { - nativeManager?.Dispose(); - nativeManager = null; - - titleStore?.Dispose(); - titleStore = null; } - } -} + var options = new MBXTileRegionLoadOptions( + xoptions.Geometry?.ToNative(), + descriptors, + metadata, + xoptions.AcceptsExpired, + (MBXNetworkRestriction)xoptions.NetworkRestriction, + xoptions.StartLocation.HasValue + ? new MBXCoordinate2D( + new CoreLocation.CLLocationCoordinate2D( + xoptions.StartLocation.Value.X, + xoptions.StartLocation.Value.Y + )) + : null, + xoptions.AvarageBytesPerSecond.HasValue + ? NSNumber.FromInt32(xoptions.AvarageBytesPerSecond.Value) + : null, + xoptions.ExtraOptions?.Wrap() + ); + + titleStore.LoadTileRegionForId( + tileId, + options, + (progress) => + { + var xprogress = new TileRegionLoadProgress + { + CompletedResourceCount = progress.CompletedResourceCount, + CompletedResourceSize = progress.CompletedResourceSize, + ErroredResourceCount = progress.ErroredResourceCount, + LoadedResourceCount = progress.LoadedResourceCount, + LoadedResourceSize = progress.LoadedResourceSize, + RequiredResourceCount = progress.RequiredResourceCount, + }; + + progressHandler?.Invoke(xprogress); + }, + (tileRegion, error) => + { + var xtileRegion = tileRegion != null + ? new TileRegion + { + CompletedResourceCount = tileRegion.CompletedResourceCount, + CompletedResourceSize = tileRegion.CompletedResourceSize, + Expires = tileRegion.Expires != null + ? DateTime.Parse(tileRegion.Expires.ToString()) + : null, + RequiredResourceCount = tileRegion.RequiredResourceCount, + Id = tileRegion.Id, + } + : null; + var xerror = error != null + ? new NSErrorException(error) + : null; + + completionHandler?.Invoke(xtileRegion, xerror); + } + ); + } + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + { + nativeManager?.Dispose(); + nativeManager = null; + + titleStore?.Dispose(); + titleStore = null; + } + } +} + diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/QueriedFeatureExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/QueriedFeatureExtensions.cs index 0079091..c78c486 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/QueriedFeatureExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/QueriedFeatureExtensions.cs @@ -5,14 +5,19 @@ namespace MapboxMaui; public static class QueriedFeatureExtensions { + public static QueriedRenderedFeature ToX(this MBMQueriedRenderedFeature src) + => new QueriedRenderedFeature + { + QueriedFeature = src.QueriedFeature.ToX(), + Layers = src.Layers, + }; public static QueriedFeature ToX(this MBMQueriedFeature src) => new QueriedFeature { Feature = src.Feature.ToX(), Source = src.Source, SourceLayer = src.SourceLayer, - // TODO Convert state - //State = src.State.ToX(), + State = src.State, }; } diff --git a/src/qs/MapboxMauiQs/usings.cs b/src/libs/Mapbox.Maui/usings.cs similarity index 55% rename from src/qs/MapboxMauiQs/usings.cs rename to src/libs/Mapbox.Maui/usings.cs index 84e44ae..b8cb2ca 100644 --- a/src/qs/MapboxMauiQs/usings.cs +++ b/src/libs/Mapbox.Maui/usings.cs @@ -1,12 +1,14 @@ -global using System; -global using System.Text.Json; +global using System.Text.Json; +global using System.Collections.ObjectModel; +global using System.Collections.Specialized; global using GeoJSON.Text; global using GeoJSON.Text.Feature; global using GeoJSON.Text.Geometry; -global using Point = Microsoft.Maui.Graphics.Point; global using MapboxMaui; global using MapboxMaui.Expressions; global using MapboxMaui.Styles; global using MapboxMaui.Offline; global using MapboxMaui.Annotations; -global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page; \ No newline at end of file +global using iOSPage = Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific.Page; +global using ScreenPosition = Microsoft.Maui.Graphics.Point; +global using MapPosition = GeoJSON.Text.Geometry.Position; \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExample.cs b/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExample.cs index db8d80a..fb2210b 100644 --- a/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExample.cs +++ b/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExample.cs @@ -34,7 +34,7 @@ public void ApplyQueryAttributes(IDictionary query) private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Point(55.70651, 12.554729); + var centerLocation = new MapPosition(55.70651, 12.554729); var cameraOptions = new CameraOptions { Center = centerLocation, @@ -56,7 +56,7 @@ private void Map_MapLoaded(object sender, EventArgs e) var feature = new Feature( new GeoJSON.Text.Geometry.Point( - new GeoJSON.Text.Geometry.Position(latitude: 55.608166, longitude: 12.65147) + new MapPosition(latitude: 55.608166, longitude: 12.65147) ), new Dictionary { { Constants.ICON_KEY, Constants.BLUE_MARKER_PROPERTY } @@ -66,7 +66,7 @@ private void Map_MapLoaded(object sender, EventArgs e) var feature1 = new Feature( new GeoJSON.Text.Geometry.Point( - new GeoJSON.Text.Geometry.Position(latitude: 55.70651, longitude: 12.554729) + new MapPosition(latitude: 55.70651, longitude: 12.554729) ), new Dictionary { { Constants.ICON_KEY, Constants.RED_MARKER_PROPERTY } diff --git a/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExampleInfo.cs index b8dd493..83f552d 100644 --- a/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/01.AddMarkersSymbol/AddMarkersSymbolExampleInfo.cs @@ -5,4 +5,6 @@ class AddMarkersSymbolExampleInfo : IExampleInfo public string Title => "Add markers to a map"; public string Subtitle => "Add markers that use different icons."; public string PageRoute => typeof(AddMarkersSymbolExample).FullName; + public int GroupIndex => 3; + public int Index => 1; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExample.cs b/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExample.cs index 595479d..60bdfee 100644 --- a/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExample.cs +++ b/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExample.cs @@ -26,7 +26,7 @@ private void Map_StyleLoaded(object sender, EventArgs e) var source = new GeoJSONSource(sourceId) { Data = new GeoJSON.Text.Geometry.Point( - new Position(55.665957, 12.550343)) + new MapPosition(55.665957, 12.550343)) }; map.Sources = new[] { source }; @@ -43,7 +43,7 @@ private void Map_StyleLoaded(object sender, EventArgs e) private void Map_MapReady(object sender, EventArgs e) { // Do any additional setup after loading the view. - var center = new Point(55.665957, 12.550343); + var center = new MapPosition(55.665957, 12.550343); var cameraOptions = new CameraOptions { Center = center, Zoom = 8, diff --git a/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExampleInfo.cs index 607df0e..c363111 100644 --- a/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/02.AddOneMarkerSymbol/AddOneMarkerSymbolExampleInfo.cs @@ -5,4 +5,6 @@ class AddOneMarkerSymbolExampleInfo : IExampleInfo public string Title => "Add a marker symbol"; public string Subtitle => "Add a blue teardrop-shaped marker image to a style and display it on the map using a SymbolLayer."; public string PageRoute => typeof(AddOneMarkerSymbolExample).FullName; + public int GroupIndex => 3; + public int Index => 2; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExample.cs b/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExample.cs index 03a7411..c0b319f 100644 --- a/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExample.cs +++ b/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExample.cs @@ -2,17 +2,17 @@ namespace MapboxMauiQs; public class AnimatedMarkerExample : ContentPage, IExamplePage, IQueryAttributable { - static class Constants + static class Constants { public const string markerIconId = "marker_icon"; public const string sourceId = "source-id"; public const double animationDuration = 2; - } + } MapboxView map; IExampleInfo info; - private Point currentPosition = new Point(64.900932, -18.167040); + private IPosition currentPosition = new MapPosition(64.900932, -18.167040); public AnimatedMarkerExample() { @@ -22,30 +22,30 @@ public AnimatedMarkerExample() map.MapReady += Map_MapReady; map.MapLoaded += Map_MapLoaded; map.Command = new Command(HandleMapTapped); - } - + } + public void ApplyQueryAttributes(IDictionary query) { info = query["example"] as IExampleInfo; Title = info?.Title; - } - - private void HandleMapTapped(MapTappedPosition point) - { - // Create a GeoJSON data source. - var feature = new Feature( - point.Point - ); - var source = new GeoJSONSource(Constants.sourceId) - { - Data = new RawGeoJSONObject( - JsonSerializer.Serialize(feature) - ) - }; - - map.Sources = new[] { source }; - } + } + + private void HandleMapTapped(MapTappedPosition point) + { + // Create a GeoJSON data source. + var feature = new Feature( + new GeoJSON.Text.Geometry.Point(point.MapPosition) + ); + var source = new GeoJSONSource(Constants.sourceId) + { + Data = new RawGeoJSONObject( + JsonSerializer.Serialize(feature) + ) + }; + + map.Sources = new[] { source }; + } private void Map_MapReady(object sender, EventArgs e) { @@ -63,29 +63,27 @@ private void Map_MapLoaded(object sender, EventArgs e) { var image = new ResolvedImage(Constants.markerIconId, "red_marker"); map.Images = new[] { image }; - - // Create a GeoJSON data source. - var feature = new Feature( - new GeoJSON.Text.Geometry.Point( - new Position(currentPosition.X, currentPosition.Y) - ) - ); - var source = new GeoJSONSource(Constants.sourceId) - { - Data = new RawGeoJSONObject( - JsonSerializer.Serialize(feature) - ) - }; - - map.Sources = new[] { source }; - - // Create a symbol layer - var symbolLayer = new SymbolLayer(id: "layer-id"); - symbolLayer.Source = Constants.sourceId; - symbolLayer.IconImage = image; - symbolLayer.IconIgnorePlacement = true; - symbolLayer.IconAllowOverlap = true; - + + // Create a GeoJSON data source. + var feature = new Feature( + new GeoJSON.Text.Geometry.Point(currentPosition) + ); + var source = new GeoJSONSource(Constants.sourceId) + { + Data = new RawGeoJSONObject( + JsonSerializer.Serialize(feature) + ) + }; + + map.Sources = new[] { source }; + + // Create a symbol layer + var symbolLayer = new SymbolLayer(id: "layer-id"); + symbolLayer.Source = Constants.sourceId; + symbolLayer.IconImage = image; + symbolLayer.IconIgnorePlacement = true; + symbolLayer.IconAllowOverlap = true; + map.Layers = new[] { symbolLayer }; } } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExampleInfo.cs index e1ff475..4f6e378 100644 --- a/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/07.AnimatedMarker/AnimatedMarkerExampleInfo.cs @@ -6,4 +6,6 @@ class AnimatedMarkerExampleInfo : IExampleInfo public string Title => "Animate Marker Position"; public string Subtitle => "Animate updates to a marker/annotation's position."; public string PageRoute => typeof(AnimatedMarkerExample).FullName; + public int GroupIndex => 3; + public int Index => 7; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml b/src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml index 6c153b7..61e97c8 100644 --- a/src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml +++ b/src/qs/MapboxMauiQs/Examples/09.BasicMap/BasicMapExample.xaml @@ -2,7 +2,7 @@ "Display a map view"; - public string Subtitle => "Create and display a map that uses the default Mapbox streets style. This example also shows how to update the starting camera for a map."; + public string Subtitle => "Create and display a map that uses the default Mapbox Standard style."; public string PageRoute => typeof(BasicMapExample).FullName; + + public int GroupIndex => 1; + + public int Index => 9; } diff --git a/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExample.cs b/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExample.cs index 8e64ca9..3185f28 100644 --- a/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExample.cs +++ b/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExample.cs @@ -120,7 +120,7 @@ private void Map_StyleLoaded(object sender, EventArgs e) layer, }; - var center = new Point(40.7135, -74.0066); + var center = new MapPosition(40.7135, -74.0066); var cameraOptions = new CameraOptions { Center = center, diff --git a/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExampleInfo.cs index d1cb81f..756b29a 100644 --- a/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/10.BuildingExtrusions/BuildingExtrusionsExampleInfo.cs @@ -5,4 +5,6 @@ class BuildingExtrusionsExampleInfo : IExampleInfo public string Title => "Display 3D buildings"; public string Subtitle => "Extrude the building layer in the Mapbox Light style using FillExtrusionLayer and set up the light position."; public string PageRoute => typeof(BuildingExtrusionsExample).FullName; + public int GroupIndex => 2; + public int Index => 10; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExample.cs index 91f70e5..22e3beb 100644 --- a/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExample.cs +++ b/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExample.cs @@ -20,7 +20,7 @@ private void Map_MapLoaded(object sender, EventArgs e) var circleAnnotations = new List(); for (int i = 0; i < 2000; i++) { - var center = new Point( + var center = new MapPosition( random.NextInt64(0, 180) - 90, random.NextInt64(0, 360) - 180); var color = new Color( @@ -29,9 +29,7 @@ private void Map_MapLoaded(object sender, EventArgs e) random.Next(0, 255)); var circleAnnotation = new CircleAnnotation( - new GeoJSON.Text.Geometry.Point( - new Position(center.X, center.Y) - ) + new GeoJSON.Text.Geometry.Point(center) ) { CircleColor = color, diff --git a/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExampleInfo.cs index 19553ff..6033ebc 100644 --- a/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/13.CircleAnnotation/CircleAnnotationExampleInfo.cs @@ -5,4 +5,6 @@ class CircleAnnotationExampleInfo : IExampleInfo public string Title => "Add Circle Annotations"; public string Subtitle => "Show circle annotations on a map"; public string PageRoute => typeof(CircleAnnotationExample).FullName; + public int GroupIndex => 3; + public int Index => 13; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExample.cs index 1f120fe..7f77fa6 100644 --- a/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExample.cs +++ b/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExample.cs @@ -36,7 +36,7 @@ private void Map_MapLoaded(object sender, EventArgs e) // and configure it with a custom image (sourced from the asset catalogue) var customPointAnnotation = new PointAnnotation( new GeoJSON.Text.Geometry.Point( - new Position(centerCoordinate.Value.X, centerCoordinate.Value.Y) + new MapPosition(centerCoordinate.Latitude, centerCoordinate.Longitude) ) ) { @@ -51,7 +51,7 @@ private void Map_MapLoaded(object sender, EventArgs e) private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Point(40.7128, -74.0060); + var centerLocation = new MapPosition(40.7128, -74.0060); var cameraOptions = new CameraOptions { Center = centerLocation, diff --git a/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExampleInfo.cs index 557ee8d..0bb8363 100644 --- a/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/19.CustomPointAnnotation/CustomPointAnnotationExampleInfo.cs @@ -5,4 +5,6 @@ class CustomPointAnnotationExampleInfo : IExampleInfo public string Title => "Add Point Annotations"; public string Subtitle => "Show point annotations on a map"; public string PageRoute => typeof(CustomPointAnnotationExample).FullName; + public int GroupIndex => 3; + public int Index => 19; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/20.CustomStyleURL/CustomStyleURLExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/20.CustomStyleURL/CustomStyleURLExampleInfo.cs index 4961af4..68d4c4a 100644 --- a/src/qs/MapboxMauiQs/Examples/20.CustomStyleURL/CustomStyleURLExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/20.CustomStyleURL/CustomStyleURLExampleInfo.cs @@ -3,10 +3,9 @@ public class CustomStyleURLExampleInfo : IExampleInfo { public string Group => "Get Started"; - public string Title => "Use a custom map style"; - public string Subtitle => "Set and use a custom map style URL."; - public string PageRoute => typeof(CustomStyleURLExample).FullName; + public int GroupIndex => 1; + public int Index => 20; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/23.DebugMap/DebugMapExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/23.DebugMap/DebugMapExampleInfo.cs index 1ce2c82..ccc5fa2 100644 --- a/src/qs/MapboxMauiQs/Examples/23.DebugMap/DebugMapExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/23.DebugMap/DebugMapExampleInfo.cs @@ -5,4 +5,6 @@ class DebugMapExampleInfo : IExampleInfo public string Title => "Debug Map"; public string Subtitle => "This example shows how the map looks with different debug options"; public string PageRoute => typeof(DebugMapExample).FullName; + public int GroupIndex => 1; + public int Index => 23; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExample.cs b/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExample.cs index 3830155..58b1e10 100644 --- a/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExample.cs +++ b/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExample.cs @@ -24,7 +24,7 @@ public void ApplyQueryAttributes(IDictionary query) private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Point(42.354950, -71.065634); + var centerLocation = new MapPosition(42.354950, -71.065634); var cameraOptions = new CameraOptions { Center = centerLocation, @@ -38,9 +38,9 @@ private void Map_MapReady(object sender, EventArgs e) private void Map_MapLoaded(object sender, EventArgs e) { var markerFeatures = new [] { - new Position(latitude: 42.354950, longitude: -71.065634), // Boston Common Park - new Position(latitude: 42.346645, longitude: -71.097293), // Fenway Park - new Position(latitude: 42.363725, longitude: -71.053694) // The Paul Revere House + new MapPosition(latitude: 42.354950, longitude: -71.065634), // Boston Common Park + new MapPosition(latitude: 42.346645, longitude: -71.097293), // Fenway Park + new MapPosition(latitude: 42.363725, longitude: -71.053694) // The Paul Revere House } .Select( x => new Feature( @@ -75,6 +75,7 @@ private void Map_MapLoaded(object sender, EventArgs e) Data = new GeoJSON.Text.Geometry.Point(), }; + // TODO Check NPE map.Sources = new[] { markerSource, selectedMarkerSource }; // Create a symbol layer for the selected marker @@ -105,8 +106,9 @@ private async void Map_MapTapped(object sender, MapTappedEventArgs e) return; } - var geometry = features.First().Feature; - var geojson = JsonSerializer.Serialize(geometry); + // TODO Check the original example + var geometry = features.First().QueriedFeature; + var geojson = JsonSerializer.Serialize(geometry.Feature.Geometry); var geoJSONSource = new GeoJSONSource(Constants.selectedMarkerSourceId) { Data = new RawGeoJSONObject(geojson), diff --git a/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExampleInfo.cs index 774c0d9..e703733 100644 --- a/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/32.IconSizeChange/IconSizeChangeExampleInfo.cs @@ -6,4 +6,6 @@ class IconSizeChangeExampleInfo : IExampleInfo public string Title => "Change icon size"; public string Subtitle => "Change icon size with Symbol layer."; public string PageRoute => typeof(IconSizeChangeExample).FullName; + public int GroupIndex => 3; + public int Index => 32; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExample.cs index 7aa3b04..20020ce 100644 --- a/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExample.cs +++ b/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExample.cs @@ -30,10 +30,10 @@ private void Map_MapReady(object sender, EventArgs e) private void Map_MapLoaded(object sender, EventArgs e) { var annotations = new List(); - var coordinates = new List { - new Position(-2.178992, -4.375974), - new Position(-4.107888, -7.639772), - new Position(2.798737, -11.439207), + var coordinates = new List { + new MapPosition(-2.178992, -4.375974), + new MapPosition(-4.107888, -7.639772), + new MapPosition(2.798737, -11.439207), }; var lineAnnotation = new PolylineAnnotation( new LineString(coordinates) @@ -46,7 +46,7 @@ private void Map_MapLoaded(object sender, EventArgs e) annotations.Add(lineAnnotation); // random add lines across the globe - var randomCoordinates = new List(); + var randomCoordinates = new List(); for (var i = 0; i < 400; i++) { randomCoordinates.Add(RandomizePosition()); @@ -80,8 +80,8 @@ private void Map_MapLoaded(object sender, EventArgs e) polylineAnnotationManager.AddAnnotations(annotations.ToArray()); } - static Position RandomizePosition() - => new Position( + static MapPosition RandomizePosition() + => new MapPosition( random.Next(-90, 90), random.Next(-180, 180) ); diff --git a/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExampleInfo.cs index a745303..91c0c47 100644 --- a/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/35.LineAnnotation/LineAnnotationExampleInfo.cs @@ -6,4 +6,6 @@ class LineAnnotationExampleInfo : IExampleInfo public string Title => "Add Polylines Annotations"; public string Subtitle => "Show polyline annotations on a map."; public string PageRoute => typeof(LineAnnotationExample).FullName; + public int GroupIndex => 3; + public int Index => 35; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExample.cs b/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExample.cs index ba0343c..d5150ff 100644 --- a/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExample.cs +++ b/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExample.cs @@ -28,7 +28,7 @@ public void ApplyQueryAttributes(IDictionary query) private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Point(38.93490939383946, -77.03619251024163); + var centerLocation = new MapPosition(38.93490939383946, -77.03619251024163); var cameraOptions = new CameraOptions { Center = centerLocation, diff --git a/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExampleInfo.cs index 281980e..8c7209c 100644 --- a/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/39.MultipleGeometries/MultipleGeometriesExampleInfo.cs @@ -6,4 +6,6 @@ class MultipleGeometriesExampleInfo : IExampleInfo public string Title => "Draw multiple geometries"; public string Subtitle => "Draw multiple shapes on a map."; public string PageRoute => typeof(MultipleGeometriesExample).FullName; + public int GroupIndex => 3; + public int Index => 39; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExample.cs b/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExample.cs index 885677c..f8d8ba4 100644 --- a/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExample.cs +++ b/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExample.cs @@ -4,7 +4,7 @@ public class OfflineManagerExample : ContentPage, IExamplePage, IQueryAttributab { MapboxView map; IExampleInfo info; - Point tokyoCoord; + IPosition tokyoCoord; string tileRegionId = @"myTileRegion"; float tokyoZoom = 12; IOfflineManager offlineManager; @@ -13,7 +13,7 @@ public OfflineManagerExample() { iOSPage.SetUseSafeArea(this, false); Content = map = new MapboxView(); - tokyoCoord = new Point(35.682027, 139.769305); + tokyoCoord = new MapPosition(35.682027, 139.769305); map.MapReady += Map_MapReady; } @@ -70,10 +70,8 @@ private void Map_MapReady(object sender, EventArgs e) ); var tileRegionLoadOptions = new TileRegionLoadOptions( - Geometry: new GeoJSON.Text.Geometry.Point( - new GeoJSON.Text.Geometry.Position(tokyoCoord.X, tokyoCoord.Y) - ), - TilesetDescriptors: new [] { tilesetDescriptorOptions }, + Geometry: new GeoJSON.Text.Geometry.Point(tokyoCoord), + TilesetDescriptors: [tilesetDescriptorOptions], AcceptsExpired: true, NetworkRestriction: NetworkRestriction.None, Metadata: new Dictionary diff --git a/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExampleInfo.cs index 2fd4934..3386128 100644 --- a/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/41.OfflineManager/OfflineManagerExampleInfo.cs @@ -5,4 +5,6 @@ class OfflineManagerExampleInfo : IExampleInfo public string Title => "Use OfflineManager and TileStore to download a region"; public string Subtitle => "Shows how to use OfflineManager and TileStore to download regions for offline use. By default, users may download up to 750 tile packs for offline use across all regions. If the limit is hit, any loadRegion call will fail until excess regions are deleted. This limit is subject to change. Please contact Mapbox if you require a higher limit. Additional charges may apply."; public string PageRoute => typeof(OfflineManagerExample).FullName; + public int GroupIndex => 7; + public int Index => 41; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExample.cs b/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExample.cs index fdeaab5..06a8b02 100644 --- a/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExample.cs +++ b/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExample.cs @@ -23,7 +23,7 @@ private void Map_MapLoaded(object sender, EventArgs e) private void Map_MapReady(object sender, EventArgs e) { // Center the map over Washington, D.C. - var centerLocation = new Microsoft.Maui.Graphics.Point(38.889215, -77.039354); + var centerLocation = new MapPosition(38.889215, -77.039354); var cameraOptions = new CameraOptions { Center = centerLocation, diff --git a/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExampleInfo.cs index b5fde1f..3ec2a02 100644 --- a/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/44.PointAnnotationClustering/PointAnnotationClusteringExampleInfo.cs @@ -5,4 +5,6 @@ class PointAnnotationClusteringExampleInfo : IExampleInfo public string Title => "Add Cluster Point Annotations"; public string Subtitle => "Show fire hydrants in Washington DC area in a cluster using point annotations."; public string PageRoute => typeof(PointAnnotationClusteringExample).FullName; + public int GroupIndex => 3; + public int Index => 44; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExample.cs index 19eb838..5af943c 100644 --- a/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExample.cs +++ b/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExample.cs @@ -16,7 +16,7 @@ public PolygonAnnotationExample() private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Microsoft.Maui.Graphics.Point(25.04579, -88.90136); + var centerLocation = new MapPosition(25.04579, -88.90136); var cameraOptions = new CameraOptions { Center = centerLocation, @@ -34,21 +34,21 @@ private void Map_StyleLoaded(object sender, EventArgs e) // outer ring new LineString( new [] { - new Position(24.51713945052515, -89.857177734375 ), - new Position(24.51713945052515, -87.967529296875 ), - new Position(26.244156283890756, -87.967529296875) , - new Position(26.244156283890756, -89.857177734375) , - new Position(24.51713945052515, -89.857177734375 ) + new MapPosition(24.51713945052515, -89.857177734375 ), + new MapPosition(24.51713945052515, -87.967529296875 ), + new MapPosition(26.244156283890756, -87.967529296875) , + new MapPosition(26.244156283890756, -89.857177734375) , + new MapPosition(24.51713945052515, -89.857177734375 ) } ), // inner ring new LineString( new [] { - new Position(25.085598897064752, -89.20898437499999), - new Position(25.085598897064752, -88.61572265625), - new Position(25.720735134412106, -88.61572265625), - new Position(25.720735134412106, -89.20898437499999), - new Position(25.085598897064752, -89.20898437499999) + new MapPosition(25.085598897064752, -89.20898437499999), + new MapPosition(25.085598897064752, -88.61572265625), + new MapPosition(25.720735134412106, -88.61572265625), + new MapPosition(25.720735134412106, -89.20898437499999), + new MapPosition(25.085598897064752, -89.20898437499999) } ) }); diff --git a/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExampleInfo.cs index ddb339e..a4a1a42 100644 --- a/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/46.PolygonAnnotation/PolygonAnnotationExampleInfo.cs @@ -5,4 +5,6 @@ class PolygonAnnotationExampleInfo : IExampleInfo public string Title => "Add a polygon annotation"; public string Subtitle => "Add a polygon annotation to the map"; public string PageRoute => typeof(PolygonAnnotationExample).FullName; + public int GroupIndex => 3; + public int Index => 46; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExample.cs b/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExample.cs new file mode 100644 index 0000000..2d30c66 --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExample.cs @@ -0,0 +1,201 @@ +namespace MapboxMauiQs; + +public class ShowHideLayerExample : ContentPage, IExamplePage, IQueryAttributable +{ + private static string museumLayerId = "museum-circle-layer"; + private static string contourLayerId = "contour-line-layer"; + + MapboxView map; + IExampleInfo info; + + public ShowHideLayerExample() + { + iOSPage.SetUseSafeArea(this, false); + Content = map = new MapboxView(); + + map.MapReady += Map_MapReady; + map.MapLoaded += Map_MapLoaded; + } + + public void ApplyQueryAttributes(IDictionary query) + { + info = query["example"] as IExampleInfo; + + Title = info?.Title; + } + + private void Map_MapReady(object sender, EventArgs e) + { + var centerLocation = new MapPosition(-13.517379, -71.977221); + var cameraOptions = new CameraOptions + { + Center = centerLocation, + Zoom = 15, + }; + + map.CameraOptions = cameraOptions; + map.MapboxStyle = MapboxStyle.MAPBOX_STREETS; + } + + private void Map_MapLoaded(object sender, EventArgs e) + { + // Setup Styles, Annotations, etc here + } + + private void AddStyleLayers() + { + // Create a custom vector tileset source. This source contains point features + // that represent museums. + // var museumsSource = new VectorSource("museum-source"); + // museumsSource.url = "mapbox://mapbox.2opop9hr"; + + // // Create CircleLayer with id and source identifier. + // var museumLayer = new CircleLayer(museumLayerId) + // { + // Source = museumsSource.Id, + // }; + + //// Specify the layer within the vector source to render on the map. + //museumLayer.sourceLayer = "museum-cusco" + + //// Use a constant circle radius and color to style the layer. + //museumLayer.circleRadius = .constant(8) + + //// `visibility` is `nil` by default. Set to `visible`. + //museumLayer.visibility = .constant(.visible) + + + //let museumColor = UIColor(red: 0.22, green: 0.58, blue: 0.70, alpha: 1.00) + //museumLayer.circleColor = .constant(StyleColor(museumColor)) + + + //var contourSource = VectorSource(id: "contour-source") + //// Add the Mapbox Terrain v2 vector tileset. Documentation for this vector tileset + //// can be found at https://docs.mapbox.com/vector-tiles/reference/mapbox-terrain-v2/ + //contourSource.url = "mapbox://mapbox.mapbox-terrain-v2" + + + //var contourLayer = LineLayer(id: Self.contourLayerId, source: contourSource.id) + + //// Assign this layer's source layer ID. + //contourLayer.sourceLayer = "contour" + + //// Style the contents of the source's contour layer. + //contourLayer.lineCap = .constant(.round) + //contourLayer.lineJoin = .constant(.round) + + //// `visibility` is `nil` by default. Set to `visible`. + //contourLayer.visibility = .constant(.visible) + + + //let contourLineColor = UIColor(red: 0.53, green: 0.48, blue: 0.35, alpha: 1.00) + //contourLayer.lineColor = .constant(StyleColor(contourLineColor)) + + //// Add the sources and layers to the map's style. + //do + // { + // try mapView.mapboxMap.addSource(museumsSource) + // try mapView.mapboxMap.addSource(contourSource) + // try mapView.mapboxMap.addLayer(museumLayer) + // try mapView.mapboxMap.addLayer(contourLayer) + // } + // catch + // { + // print("Error when adding sources and layers: \(error.localizedDescription)") + // } + // } + + + //@objc func toggleMuseumLayerVisibility(sender: UISwitch) { + // // Update the museum layer's visibility based on whether the switch + // // is on. `visibility` is `nil` by default. + // do + // { + // try mapView.mapboxMap.updateLayer(withId: Self.museumLayerId, type: CircleLayer.self) { + // layer in + //layer.visibility = .constant(sender.isOn?.visible : .none) + // } + // } + // catch + // { + // print("Failed to update the visibility for layer with id \(Self.museumLayerId). Error: \(error.localizedDescription)") + // } + // } + + + // @objc func toggleContourLayerVisibility(sender: UISwitch) { + // // Update the contour layer's visibility based on whether the switch + // // is on. + // do + // { + // try mapView.mapboxMap.updateLayer(withId: Self.contourLayerId, type: CircleLayer.self) { + // layer in + //layer.visibility = .constant(sender.isOn?.visible : .none) + // } + // } + // catch + // { + // print("Failed to update the visibility for layer with id \(Self.contourLayerId). Error: \(error.localizedDescription)") + // } + // } + + + // func addVisibilitySwitches() { + // // Create switches to toggle the layers' visibility. + // let museumSwitch = UISwitch() + // museumSwitch.addTarget(self, action: #selector(toggleMuseumLayerVisibility(sender:)), for: .valueChanged) + //museumSwitch.isOn = true + // museumSwitch.translatesAutoresizingMaskIntoConstraints = false + + + // let contourSwitch = UISwitch() + // contourSwitch.addTarget(self, action: #selector(toggleContourLayerVisibility(sender:)), for: .valueChanged) + //contourSwitch.isOn = true + // contourSwitch.translatesAutoresizingMaskIntoConstraints = false + + //// Add labels for the toggles. + // let museumLabel = UILabel() + // museumLabel.text = "Show museums" + // museumLabel.translatesAutoresizingMaskIntoConstraints = false + + + // let contourLabel = UILabel() + // contourLabel.text = "Show contours" + // contourLabel.translatesAutoresizingMaskIntoConstraints = false + + + // let museumStackView = UIStackView(arrangedSubviews: [museumLabel, museumSwitch]) + // museumStackView.translatesAutoresizingMaskIntoConstraints = false + // let contourStackView = UIStackView(arrangedSubviews: [contourLabel, contourSwitch]) + // contourStackView.translatesAutoresizingMaskIntoConstraints = false + + + // let stackView = UIStackView(arrangedSubviews: [museumStackView, contourStackView]) + // stackView.translatesAutoresizingMaskIntoConstraints = false + // stackView.spacing = UIStackView.spacingUseSystem + // stackView.axis = .vertical + // stackView.isLayoutMarginsRelativeArrangement = true + // stackView.directionalLayoutMargins = .init(top: 10, leading: 10, bottom: 10, trailing: 10) + + + // let backdropView = UIVisualEffectView(effect: UIBlurEffect(style: .regular)) + // backdropView.translatesAutoresizingMaskIntoConstraints = false + // backdropView.layer.cornerRadius = 10 + // backdropView.clipsToBounds = true + + + // stackView.insertSubview(backdropView, at: 0) + // view.addSubview(stackView) + + //// Layout the switches and labels. + // NSLayoutConstraint.activate([ + // mapView.ornaments.logoView.topAnchor.constraint(equalToSystemSpacingBelow: stackView.bottomAnchor, multiplier: 1), + // stackView.leadingAnchor.constraint(equalToSystemSpacingAfter: mapView.safeAreaLayoutGuide.leadingAnchor, multiplier: 1), + // mapView.safeAreaLayoutGuide.trailingAnchor.constraint(equalToSystemSpacingAfter: stackView.trailingAnchor, multiplier: 1), + // stackView.topAnchor.constraint(equalTo: backdropView.topAnchor), + // stackView.bottomAnchor.constraint(equalTo: backdropView.bottomAnchor), + // stackView.leadingAnchor.constraint(equalTo: backdropView.leadingAnchor), + // stackView.trailingAnchor.constraint(equalTo: backdropView.trailingAnchor) + // ]) + } +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExampleInfo.cs new file mode 100644 index 0000000..008980f --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/51.ShowHideLayer/ShowHideLayerExampleInfo.cs @@ -0,0 +1,11 @@ +namespace MapboxMauiQs; + +class ShowHideLayerExampleInfo : IExampleInfo +{ + public string Group => "User interaction"; + public string Title => "Show and hide a layer"; + public string Subtitle => "Allow the user to toggle the visibility of a CircleLayer and LineLayer on a map."; + public string PageRoute => typeof(ShowHideLayerExample).FullName; + public int GroupIndex => 8; + public int Index => 51; +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExample.cs b/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExample.cs index 6f01b41..7181a82 100644 --- a/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExample.cs +++ b/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExample.cs @@ -67,7 +67,7 @@ private void @switch_Toggled(object sender, ToggledEventArgs e) private void Map_MapReady(object sender, EventArgs e) { - var center = new Point(35.67283, 127.60597); + var center = new MapPosition(35.67283, 127.60597); var cameraOptions = new CameraOptions { diff --git a/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExampleInfo.cs index 91efb6f..eedff77 100644 --- a/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/52.SkyLayer/SkyLayerExampleInfo.cs @@ -5,4 +5,6 @@ class SkyLayerExampleInfo : IExampleInfo public string Title => "Add a sky layer"; public string Subtitle => "Add a customizable sky layer to simulate natural lighting with a Terrain layer."; public string PageRoute => typeof(SkyLayerExample).FullName; + public int GroupIndex => 2; + public int Index => 52; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExample.cs b/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExample.cs index f2082d6..9fb4293 100644 --- a/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExample.cs +++ b/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExample.cs @@ -145,7 +145,7 @@ static SymbolLayer CreateNumberLayer(string sourceId) private void Map_MapReady(object sender, EventArgs e) { // Setup Map here - var center = new Point(38.889215, -77.039354); + var center = new MapPosition(38.889215, -77.039354); var cameraOptions = new CameraOptions { Center = center, diff --git a/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExampleInfo.cs index 010b9ae..9ff0bb6 100644 --- a/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/58.SymbolClustering/SymbolClusteringExampleInfo.cs @@ -5,4 +5,6 @@ class SymbolClusteringExampleInfo : IExampleInfo public string Title => "Add Cluster Symbol Annotations"; public string Subtitle => "Show fire hydrants in Washington DC area in a cluster using a symbol layer."; public string PageRoute => typeof(SymbolClusteringExample).FullName; + public int GroupIndex => 3; + public int Index => 58; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExample.cs b/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExample.cs index b4eb3ba..4bfb411 100644 --- a/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExample.cs +++ b/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExample.cs @@ -47,7 +47,7 @@ private void Map_StyleLoaded(object sender, EventArgs e) private void Map_MapReady(object sender, EventArgs e) { - var mapCenter = new Point(32.6141, -114.34411); + var mapCenter = new MapPosition(32.6141, -114.34411); var cameraOptions = new CameraOptions { Center = mapCenter, diff --git a/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExampleInfo.cs index d5b6767..8b39732 100644 --- a/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/59.Terrain/TerrainExampleInfo.cs @@ -5,4 +5,6 @@ class TerrainExampleInfo : IExampleInfo public string Title => "Show 3D terrain"; public string Subtitle => "Show realistic elevation by enabling terrain."; public string PageRoute => typeof(TerrainExample).FullName; + public int GroupIndex => 2; + public int Index => 59; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExample.cs index 36d1635..8528c05 100644 --- a/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExample.cs +++ b/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExample.cs @@ -38,7 +38,7 @@ public void ApplyQueryAttributes(IDictionary query) private void Map_MapReady(object sender, EventArgs e) { - var centerLocation = new Point(39.7128, -75.0060); + var centerLocation = new MapPosition(39.7128, -75.0060); var cameraOptions = new CameraOptions { Center = centerLocation, @@ -63,37 +63,35 @@ private void Map_MapLoaded(object sender, EventArgs e) AddPointAndViewAnnotationAt(map.CameraOptions.Center); } - private void AddPointAndViewAnnotationAt(Point? coordinate) + private void AddPointAndViewAnnotationAt(IPosition coordinate) { if (coordinate is null) return; - AddPointAnnotationAt(coordinate.Value); - AddViewAnnotationAt(coordinate.Value); + AddPointAnnotationAt(coordinate); + AddViewAnnotationAt(coordinate); } - private void AddViewAnnotationAt(Point value) + private void AddViewAnnotationAt(IPosition value) { var options = new ViewAnnotationOptions { - Geometry = new GeoJSON.Text.Geometry.Point( - new Position(value.X, value.Y)), + Geometry = new GeoJSON.Text.Geometry.Point(value), Width = 128, Height = 64, AssociatedFeatureId = Constants.markerId, AllowOverlap = false, Anchor = ViewAnnotationAnchor.Bottom, OffsetY = markerHeight, - Title = $"Lat={value.X}, Lng={value.Y}", + Title = $"Lat={value.Latitude}, Lng={value.Longitude}", }; map.ViewAnnotations = new[] { options }; } - private void AddPointAnnotationAt(Point value) + private void AddPointAnnotationAt(IPosition value) { var pointAnnotation = new PointAnnotation( - new GeoJSON.Text.Geometry.Point( - new Position(value.X, value.Y)), + new GeoJSON.Text.Geometry.Point(value), id: Constants.markerId) { IconImage = Constants.blueIconId, diff --git a/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExampleInfo.cs index e1d4dda..41ffb35 100644 --- a/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExampleInfo.cs +++ b/src/qs/MapboxMauiQs/Examples/64.ViewAnnotationWithPointAnnotation/ViewAnnotationWithPointAnnotationExampleInfo.cs @@ -6,4 +6,6 @@ class ViewAnnotationWithPointAnnotationExampleInfo : IExampleInfo public string Title => "[WIP] View annotation with point annotation"; public string Subtitle => "Add view annotation to a point annotation"; public string PageRoute => typeof(ViewAnnotationWithPointAnnotationExample).FullName; + public int GroupIndex => 3; + public int Index => 64; } \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExample.cs b/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExample.cs new file mode 100644 index 0000000..9cf8152 --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExample.cs @@ -0,0 +1,73 @@ +namespace MapboxMauiQs; + +public class AnimatePointAnnotationExample : ContentPage, IExamplePage, IQueryAttributable +{ + MapboxView map; + IExampleInfo info; + + IPointAnnotationManager pointAnnotationManager; + + private int noAnimateCarNum = 10; + private int animateCarNum = 10; + private long animateDuration = 5000L; + + + public AnimatePointAnnotationExample() + { + iOSPage.SetUseSafeArea(this, false); + Content = map = new MapboxView(); + + map.MapReady += Map_MapReady; + map.MapLoaded += Map_MapLoaded; + } + + public void ApplyQueryAttributes(IDictionary query) + { + info = query["example"] as IExampleInfo; + + Title = info?.Title; + } + + private void Map_MapReady(object sender, EventArgs e) + { + var centerLocation = new MapPosition(55.665957, 12.550343); + var cameraOptions = new CameraOptions + { + Center = centerLocation, + Zoom = 12, + }; + + map.CameraOptions = cameraOptions; + map.MapboxStyle = MapboxStyle.STANDARD; + } + + private void Map_MapLoaded(object sender, EventArgs e) + { + var image = new ResolvedImage("ic_car_top", "ic_car_top"); + map.Images = new[] { image }; + // Setup Styles, Annotations, etc here + pointAnnotationManager = map.AnnotationController.CreatePointAnnotationManager( + "id", LayerPosition.Unknown() + ); + pointAnnotationManager.IconPitchAlignment = IconPitchAlignment.Map; + + var noAnimateItems = new List(); + for ( int i = 0; i< noAnimateCarNum; i++) { + var point = RandomizePoint(); + noAnimateItems.Add(new PointAnnotation(point, Guid.NewGuid().ToString()) { + IconImage = "ic_car_top", + }); + } + pointAnnotationManager.AddAnnotations(noAnimateItems.ToArray()); + } + + private GeoJSON.Text.Geometry.Point RandomizePoint() + { + CoordinateBounds bounds = map.MapboxController.GetCoordinateBoundsForCamera(map.CameraOptions); + var generator = new Random(); + var lat = bounds.Southwest.Latitude + (bounds.Northeast.Latitude - bounds.Southwest.Latitude) * generator.NextDouble(); + var lon = bounds.Southwest.Longitude + (bounds.Northeast.Longitude - bounds.Southwest.Longitude) * generator.NextDouble(); + var position = new MapPosition(lat, lon); + return new GeoJSON.Text.Geometry.Point(position); + } +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExampleInfo.cs new file mode 100644 index 0000000..fdfc7cc --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/Annotations/58.AnimatePointAnnotation/AnimatePointAnnotationExampleInfo.cs @@ -0,0 +1,12 @@ +namespace MapboxMauiQs; + +class AnimatePointAnnotationExampleInfo : IExampleInfo +{ + public string Group => "Annotations"; + public string Title => "Animate Point Annotation"; + public string Subtitle => "Animate PointAnnotations on a map"; + public string PageRoute => typeof(AnimatePointAnnotationExample).FullName; + + public int GroupIndex => 3; + public int Index => 58; +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/MainPage.xaml.cs b/src/qs/MapboxMauiQs/MainPage.xaml.cs index 0888f71..31e1073 100644 --- a/src/qs/MapboxMauiQs/MainPage.xaml.cs +++ b/src/qs/MapboxMauiQs/MainPage.xaml.cs @@ -7,293 +7,14 @@ public MainPage(IEnumerable examples) InitializeComponent(); var items = examples + .OrderBy(x => x.GroupIndex) + .ThenBy(x => x.Index) .GroupBy(x => x.Group) .ToList(); BindableLayout.SetItemsSource(exampleList, items); } - // Examples that show how to get started with Mapbox, such as creating a basic map view or setting a style once. - static List gettingStartedExamples = new List { - new ExampleItemModel {Title = "Display a map view", - Subtitle = @" -Create and display a map that uses the default Mapbox streets style. This example also shows how to update the starting camera for a map. - ", - PageRoute = "BasicMapExample", }, - new ExampleItemModel {Title = "Use a custom map style", - Subtitle = "Set and use a custom map style URL.", - PageRoute = "CustomStyleURLExample", }, - new ExampleItemModel {Title = "Display a map view using storyboard", - Subtitle = "Create and display a map using a storyboard.", - PageRoute = "StoryboardMapViewExample", }, - new ExampleItemModel {Title = "Debug Map", - Subtitle = "This example shows how the map looks with different debug options", - PageRoute = "DebugMapExample", }, - }; - - // Examples that show how to use 3D terrain or fill extrusions. - static ListthreeDExamples = new List { - new ExampleItemModel {Title = "Show 3D terrain", - Subtitle = "Show realistic elevation by enabling terrain.", - PageRoute = "TerrainExample", }, - new ExampleItemModel {Title = "SceneKit rendering on map", - Subtitle = "Use custom layer to render SceneKit model over terrain.", - PageRoute = "SceneKitExample", }, - new ExampleItemModel {Title = "Display 3D buildings", - Subtitle = "Extrude the building layer in the Mapbox Light style using FillExtrusionLayer and set up the light position.", - PageRoute = "BuildingExtrusionsExample", }, - new ExampleItemModel {Title = "Add a sky layer", - Subtitle = "Add a customizable sky layer to simulate natural lighting with a Terrain layer.", - PageRoute = "SkyLayerExample", } - }; - - // Examples that focus on annotations. - static ListannotationExamples = new List { - new ExampleItemModel {Title = "Add a polygon annotation", - Subtitle = "Add a polygon annotation to the map.", - PageRoute = "PolygonAnnotationExample", }, - new ExampleItemModel {Title = "Add a marker symbol", - Subtitle = "Add a blue teardrop-shaped marker image to a style and display it on the map using a SymbolLayer.", - PageRoute = "AddOneMarkerSymbolExample", }, - new ExampleItemModel {Title = "Add Circle Annotations", - Subtitle = "Show circle annotations on a map", - PageRoute = "CircleAnnotationExample", }, - new ExampleItemModel {Title = "Add Cluster Symbol Annotations", - Subtitle = "Show fire hydrants in Washington DC area in a cluster using a symbol layer.", - PageRoute = "SymbolClusteringExample", }, - new ExampleItemModel {Title = "Add Cluster Point Annotations", - Subtitle = "Show fire hydrants in Washington DC area in a cluster using point annotations.", - PageRoute = "PointAnnotationClusteringExample", }, - new ExampleItemModel {Title = "Add markers to a map", - Subtitle = "Add markers that use different icons.", - PageRoute = "AddMarkersSymbolExample", }, - new ExampleItemModel {Title = "Add Point Annotations", - Subtitle = "Show point annotations on a map", - PageRoute = "CustomPointAnnotationExample", }, - new ExampleItemModel {Title = "Add Polylines Annotations", - Subtitle = "Show polyline annotations on a map.", - PageRoute = "LineAnnotationExample", }, - new ExampleItemModel {Title = "Animate Marker Position", - Subtitle = "Animate updates to a marker/annotation's position.", - PageRoute = "AnimatedMarkerExample", }, - new ExampleItemModel {Title = "Change icon size", - Subtitle = "Change icon size with Symbol layer.", - PageRoute = "IconSizeChangeExample", }, - new ExampleItemModel {Title = "Draw multiple geometries", - Subtitle = "Draw multiple shapes on a map.", - PageRoute = "MultipleGeometriesExample", }, - new ExampleItemModel {Title = "Use a map & annotations with SwiftUI", - Subtitle = "Use the UIViewRepresentable protocol to wrap a MapView in a SwiftUI view.", - PageRoute = "SwiftUIExample", }, - new ExampleItemModel {Title = "View annotation with point annotation", - Subtitle = "Add view annotation to a point annotation", - PageRoute = "ViewAnnotationWithPointAnnotationExample", }, - new ExampleItemModel {Title = "View annotations: basic example", - Subtitle = "Add view annotation on a map with a click.", - PageRoute = "ViewAnnotationBasicExample", }, - new ExampleItemModel {Title = "View annotations: advanced example", - Subtitle = "Add view annotations anchored to a symbol layer feature.", - PageRoute = "ViewAnnotationMarkerExample", }, - new ExampleItemModel {Title = "View annotations: Frame list of annotations", - Subtitle = "Animates to camera framing the list of selected view annotations.", - PageRoute = "FrameViewAnnotationsExample", }, - new ExampleItemModel {Title = "View annotations: animation", - Subtitle = "Animate a view annotation along a route", - PageRoute = "ViewAnnotationAnimationExample", } - }; - - // Examples that focus on setting, animating, or otherwise changing the map's camera and viewport. - static ListcameraExamples = new List { - new ExampleItemModel {Title = "Use custom camera animations", - Subtitle = @" -Animate the map camera to a new position using camera animators. Individual camera properties such as zoom, bearing, and center coordinate can be animated independently. - ", - PageRoute = "CameraAnimatorsExample", }, - new ExampleItemModel {Title = "Use camera animations", - Subtitle = "Use ease(to:) to animate updates to the camera's position.", - PageRoute = "CameraAnimationExample", }, - new ExampleItemModel {Title = "Viewport", - Subtitle = "Viewport camera showcase", - PageRoute = "ViewportExample", }, - new ExampleItemModel {Title = "Advanced Viewport Gestures", - Subtitle = "Viewport configured to allow gestures", - PageRoute = "AdvancedViewportGesturesExample", }, - new ExampleItemModel {Title = "Filter symbols based on pitch and distance", - Subtitle = "Use pitch and distance-from-center expressions in the filter field of a symbol layer to remove large size POI labels in the far distance at high pitch", - PageRoute = "PitchAndDistanceExample", }, - }; - - // Miscellaneous examples - public static ListlabExamples = new List { - new ExampleItemModel {Title = "Resizable image", - Subtitle = "Add a resizable image with cap insets to a style.", - PageRoute = "ResizableImageExample", }, - new ExampleItemModel {Title = "Geojson performance", - Subtitle = "Display long route as large geojson", - PageRoute = "LargeGeoJSONPerformanceExample", } - }; - - // Examples that focus on displaying the user's location. - public static ListlocationExamples = new List { - new ExampleItemModel {Title = "Display the user's location", - Subtitle = "Display the user's location on a map with the default user location puck.", - PageRoute = "TrackingModeExample", }, - new ExampleItemModel {Title = "Basic pulsing circle", - Subtitle = "Display sonar-like animation radiating from the location puck.", - PageRoute = "BasicLocationPulsingExample", }, - new ExampleItemModel {Title = "Customize the location puck", - Subtitle = "Customized the location puck on the map", - PageRoute = "Custom2DPuckExample", }, - new ExampleItemModel {Title = "Use a 3D model to show the user's location", - Subtitle = "A 3D model is used to represent the user's location.", - PageRoute = "Custom3DPuckExample", }, - new ExampleItemModel {Title = "Add a custom location provider", - Subtitle = "Display the location puck at a custom location.", - PageRoute = "CustomLocationProviderExample", }, - new ExampleItemModel {Title = "Simulate navigation", - Subtitle = "Simulate a driving trip from LA to San Francisco along a pre-defined route", - PageRoute = "NavigationSimulatorExample", }, - }; - - // Examples that highlight using the Offline APIs. - - static ListofflineExamples = new List { - new ExampleItemModel {Title = "Use OfflineManager and TileStore to download a region", - Subtitle = @" -Shows how to use OfflineManager and TileStore to download regions for offline use. - -By default, users may download up to 750 tile packs for offline use across all regions. If the limit is hit, any loadRegion call will fail until excess regions are deleted. This limit is subject to change. Please contact Mapbox if you require a higher limit. Additional charges may apply. - ", - PageRoute = "OfflineManagerExample", } - }; - - // Examples that show how to use the map's snapshotter. - static ListsnapshotExamples = new List { - new ExampleItemModel {Title = "Create a static map snapshot", - Subtitle = @" -Create a static, non-interactive image of a map style with specified camera position. The resulting snapshot is provided as a `UIImage`. -The map on top is interactive. The bottom one is a static snapshot. - ", - PageRoute = "SnapshotterExample", }, - new ExampleItemModel {Title = "Draw on a static snapshot with Core Graphics", - Subtitle = @" -Use the overlayHandler parameter to draw on top of a snapshot using Core Graphhics APIs. - ", - PageRoute = "SnapshotterCoreGraphicsExample", }, - -}; - - // Examples that highlight how to set or modify the map's style and its contents. - static ListstyleExamples = new List { - new ExampleItemModel {Title = "Display multiple icon images in a symbol layer", - Subtitle = @" - Add point data and several images to a style and use the switchCase and get expressions to choose which image to display at each point in a SymbolLayer based on a data property. - ", - PageRoute = "DataDrivenSymbolsExample", }, - new ExampleItemModel {Title = "Change the position of a layer", - Subtitle = "Insert a specific layer above or below other layers.", - PageRoute = "LayerPositionExample", }, - new ExampleItemModel {Title = "Cluster points within a layer", - Subtitle = "Create a circle layer from a geoJSON source and cluster the points from that source. The clusters will update as the map's camera changes.", - PageRoute = "PointClusteringExample", }, - new ExampleItemModel {Title = "Animate a line layer", - Subtitle = "Animate updates to a line layer from a geoJSON source.", - PageRoute = "AnimateGeoJSONLineExample", }, - new ExampleItemModel {Title = "Animate a style layer", - Subtitle = "Animate the position of a style layer by updating its source data.", - PageRoute = "AnimateLayerExample", }, - new ExampleItemModel {Title = "Add external vector tiles", - Subtitle = "Add vector map tiles from an external source, using the {z}/{x}/{y} URL scheme.", - PageRoute = "ExternalVectorSourceExample", }, - new ExampleItemModel {Title = "Use interpolate colors between zoom level", - Subtitle = @" - Use an interpolate expression to style the background layer color depending on zoom level. - ", - PageRoute = "ColorExpressionExample", }, - new ExampleItemModel {Title = "Add a custom rendered layer", - Subtitle = "Add a custom rendered Metal layer.", - PageRoute = "CustomLayerExample", }, - new ExampleItemModel {Title = "Add a line with a color gradient", - Subtitle = "Load a polyline to a style using GeoJSONSource, display it on a map using LineLayer, and style it with a rainbow color gradient.", - PageRoute = "LineGradientExample", }, - new ExampleItemModel {Title = "Change the map's style", - Subtitle = "Switch between local and default Mapbox styles for the same map view.", - PageRoute = "SwitchStylesExample", }, - new ExampleItemModel {Title = "Change the map's language", - Subtitle = "Switch between supported languages for Symbol Layers", - PageRoute = "LocalizationExample", }, - new ExampleItemModel {Title = "Add animated weather data", - Subtitle = "Load a raster image to a style using ImageSource and display it on a map as animated weather data using RasterLayer.", - PageRoute = "AnimateImageLayerExample", }, - new ExampleItemModel {Title = "Add a raster tile source", - Subtitle = "Add third-party raster tiles to a map.", - PageRoute = "RasterTileSourceExample", }, - new ExampleItemModel {Title = "Show and hide layers", - Subtitle = "Allow the user to toggle the visibility of a CircleLayer and LineLayer on a map.", - PageRoute = "ShowHideLayerExample", }, - new ExampleItemModel {Title = "Add live data", - Subtitle = "Update feature coordinates from a geoJSON source in real time.", - PageRoute = "LiveDataExample", }, - new ExampleItemModel {Title = "Join data to vector geometry", - Subtitle = "Join local JSON data with vector tile geometries.", - PageRoute = "DataJoinExample", }, - new ExampleItemModel {Title = "Use a distance expression", Subtitle = "Use a distance style expression to show features within a specific radius.", PageRoute = "DistanceExpressionExample", } - }; - - // Examples that show use cases related to user interaction with the map. - static ListuserInteractionExamples = new List { - new ExampleItemModel {Title = "Find features at a point", - Subtitle = "Query the map for rendered features belonging to a specific layer.", - PageRoute = "FeaturesAtPointExample", }, - new ExampleItemModel {Title = "Use Feature State", - Subtitle = "Manipulate map styling with feature states and expressions.", - PageRoute = "FeatureStateExample", }, - new ExampleItemModel {Title = "Restrict the map's coordinate bounds", - Subtitle = "Prevent the map from panning outside the specified coordinate bounds.", - PageRoute = "RestrictCoordinateBoundsExample", }, - new ExampleItemModel {Title = "Add an interactive clustered layer", - Subtitle = "Display an alert controller after selecting a feature.", - PageRoute = "SymbolClusteringExample", }, - }; - - // Examples that show map accessibility features - static ListaccessibilityExamples = new List { - new ExampleItemModel {Title = "Access map features using VoiceOver", - Subtitle = "Use VoiceOver to highlight annotations and hear their associated features.", - PageRoute = "VoiceOverAccessibilityExample", }, - }; - - // Examples that display maps using the globe projection - static ListglobeAndAtmosphere = new List { - new ExampleItemModel {Title = "Display a globe", - Subtitle = "Create a map using the globe projection.", - PageRoute = "GlobeExample", }, - new ExampleItemModel {Title = "Fly-to camera animation", - Subtitle = "Smoothly interpolate between locations with the fly-to animation.", - PageRoute = "GlobeFlyToExample", }, - new ExampleItemModel {Title = "Create a rotating globe", - Subtitle = "Display your map as an interactive, rotating globe.", - PageRoute = "SpinningGlobeExample", }, - new ExampleItemModel {Title = "Visualize data as a heatmap", - Subtitle = "Display your heatmap using the globe projection.", - PageRoute = "HeatmapLayerGlobeExample", } - }; - - static Dictionary> all = new Dictionary> { - { "Getting started", gettingStartedExamples }, - { "3D and Fill Extrusions", threeDExamples }, - {"Annotations", annotationExamples }, - { "Camera", cameraExamples}, - {"Lab", labExamples }, - {"Location", locationExamples }, - {"Offline", offlineExamples }, - {"Snapshot", snapshotExamples}, - {"Style", styleExamples}, - {"User Interaction", userInteractionExamples}, - {"Accessibility", accessibilityExamples}, - { "Globe and Atmosphere", globeAndAtmosphere}, - }; - void TapGestureRecognizer_Tapped(System.Object sender, Microsoft.Maui.Controls.TappedEventArgs e) { var example = (sender as VisualElement).BindingContext as IExampleInfo; @@ -304,7 +25,10 @@ void TapGestureRecognizer_Tapped(System.Object sender, Microsoft.Maui.Controls.T { { nameof(example), example } }).ContinueWith(t => { - + if (t.IsFaulted) + { + System.Diagnostics.Debug.WriteLine(t.Exception.StackTrace); + } }); } } diff --git a/src/qs/MapboxMauiQs/MapboxMauiQs.csproj b/src/qs/MapboxMauiQs/MapboxMauiQs.csproj index f8da1fb..3055141 100644 --- a/src/qs/MapboxMauiQs/MapboxMauiQs.csproj +++ b/src/qs/MapboxMauiQs/MapboxMauiQs.csproj @@ -2,7 +2,7 @@ - net7.0-android;net7.0-ios + net8.0-android;net8.0-ios Exe MapboxMauiQs true @@ -11,28 +11,25 @@ false - MapboxQs + tv.MapbX - tech.tuyen-vuduc.mapboxmauiqs + dev.tuyentv.quickstart.dotnet.maui.mapbox cecaadf0-85bf-4ffd-9326-6c5c11457a29 1.0 1 - 15.4 - 21.0 + 15.0 + 27.0 + $(MSBuildProjectName) - - ios-arm64 - - - + false - + false @@ -52,58 +49,79 @@ + + + + Shared\%(Filename)%(Extension) + + + usings.cs + + + Shared\%(RecursiveDir)%(Filename)%(Extension) + + + + - + - + - + - + + + + + + + + + - - - - - + + + + + + + + Platforms\Android\Shared\%(RecursiveDir)%(Filename)%(Extension) + - - - + + + + + Platforms\iOS\Shared\%(RecursiveDir)%(Filename)%(Extension) + - - + + + + true + Apple Development: Created via API (X3MP9CYJPQ) + VS: WildCard Development - - - - - - - - - diff --git a/src/qs/MapboxMauiQs/MapboxMauiQs.targets b/src/qs/MapboxMauiQs/MapboxMauiQs.targets index 9341ebb..5e1c4c1 100644 --- a/src/qs/MapboxMauiQs/MapboxMauiQs.targets +++ b/src/qs/MapboxMauiQs/MapboxMauiQs.targets @@ -3,19 +3,19 @@ - maven { - url 'https://api.mapbox.com/downloads/v2/releases/maven' - authentication { - basic(BasicAuthentication) + maven { + url = uri("https://api.mapbox.com/downloads/v2/releases/maven") + authentication { + create<BasicAuthentication>("basic") + } + credentials { + // Do not change the username below. + // This should always be `mapbox` (not your username). + username = "mapbox" + // Use the secret token you stored in gradle.properties as the password + password = providers.gradleProperty("MAPBOX_DOWNLOADS_TOKEN").get() + } } - credentials { - // Do not change the username below. - // This should always be `mapbox` (not your username). - username = "mapbox" - // Use the secret token you stored in gradle.properties as the password - password = MAPBOX_DOWNLOADS_TOKEN - } - } diff --git a/src/qs/MapboxMauiQs/Models/IExample.cs b/src/qs/MapboxMauiQs/Models/IExample.cs index 65feb10..1ffc180 100644 --- a/src/qs/MapboxMauiQs/Models/IExample.cs +++ b/src/qs/MapboxMauiQs/Models/IExample.cs @@ -2,7 +2,9 @@ public interface IExampleInfo { + int GroupIndex { get; } string Group { get; } + int Index { get; } string Title { get; } string Subtitle { get; } string PageRoute { get; } diff --git a/src/qs/MapboxMauiQs/Platforms/Android/AndroidManifest.xml b/src/qs/MapboxMauiQs/Platforms/Android/AndroidManifest.xml index e125d19..0bd9613 100644 --- a/src/qs/MapboxMauiQs/Platforms/Android/AndroidManifest.xml +++ b/src/qs/MapboxMauiQs/Platforms/Android/AndroidManifest.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Resources/Images/ic_car_top.svg b/src/qs/MapboxMauiQs/Resources/Images/ic_car_top.svg new file mode 100644 index 0000000..e5b1122 --- /dev/null +++ b/src/qs/MapboxMauiQs/Resources/Images/ic_car_top.svg @@ -0,0 +1,8 @@ + + + diff --git a/src/qs/MapboxMauiQs/Resources/Images/ic_clear.png b/src/qs/MapboxMauiQs/Resources/Images/ic_clear.png new file mode 100644 index 0000000..e6ac900 Binary files /dev/null and b/src/qs/MapboxMauiQs/Resources/Images/ic_clear.png differ diff --git a/src/qs/MapboxMauiQs/Resources/Images/ic_taxi_top.png b/src/qs/MapboxMauiQs/Resources/Images/ic_taxi_top.png new file mode 100644 index 0000000..09f84fd Binary files /dev/null and b/src/qs/MapboxMauiQs/Resources/Images/ic_taxi_top.png differ diff --git a/tools/generator/index.js b/tools/generator/index.js index a32cb98..650d59e 100644 --- a/tools/generator/index.js +++ b/tools/generator/index.js @@ -36,7 +36,9 @@ const swift2CsTypeMapping = { var commonTypeToConversionNameMapping = { 'bool': 'boolean', }; -generateSourcePropertiesObjc('GeoJSON'); +// generateSourcePropertiesObjc('Vector'); + +// generateLayerPropertiesObjc function generateLayerPropertiesObjc(layerName) { var topLines = `// This file is generated.