Skip to content

Commit 4d19bde

Browse files
authored
feat: View annotation (WIP) (#44)
* - move classes/interfaces to their own files * - move CameraChangedEventArgs to Camera namespace * - move IAnnotationController to Annotations namespace * - WIP - add view annotation sample * - try framing the annotationview * get fragmentmanager from service instead * - Use ContentView for ViewAnnotation instead * fix: ScaleBarVisibility for Android * - Mapbox v11.7.1 * - assign CameraOptions and Style at creation * - move to new page from a map page * - use Mapbox SDK v11.8.0 * - fix issue of wrong LayerPosition * - important fixes from contributor
1 parent 69909c3 commit 4d19bde

File tree

49 files changed

+1066
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1066
-438
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace MapboxMaui;
2+
3+
public interface IMapboxController
4+
{
5+
IPosition GetMapPosition(ScreenPosition position);
6+
CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions);
7+
ScreenPosition GetScreenPosition(IPosition position);
8+
CameraOptions? CameraForCoordinates(
9+
IEnumerable<IPosition> coordinates,
10+
CameraOptions? cameraOptions = default,
11+
Thickness? coordinatesPadding = default,
12+
double? maxZoom = default,
13+
ScreenPosition? offset = default
14+
);
15+
void CameraForCoordinates(
16+
IEnumerable<IPosition> coordinates,
17+
Action<CameraOptions?> completion,
18+
CameraOptions? cameraOptions = default,
19+
Thickness? coordinatesPadding = default,
20+
double? maxZoom = default,
21+
ScreenPosition? offset = default
22+
);
23+
void SetSourcePropertyFor<T>(string sourceId, string propertyName, T value, Action<Exception> completion = default);
24+
void SetLayerPropertyFor<T>(string layerId, string propertyName, T value, Action<Exception> completion = default);
25+
}

src/libs/Mapbox.Maui/IMapboxView.cs

+5-82
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using MapboxMaui.Locations;
66
using MapboxMaui.Query;
77
using MapboxMaui.Styles;
8+
using MapboxMaui.ViewAnnotations;
89
using MapboxMaui.Viewport;
910

1011
public partial interface IMapboxView : IView
@@ -25,12 +26,13 @@ public partial interface IMapboxView : IView
2526

2627
IEnumerable<ResolvedImage> Images { get; set; }
2728

28-
IEnumerable<ViewAnnotationOptions> ViewAnnotations { get; set; }
29-
3029
Terrain Terrain { get; set; }
3130

3231
Light Light { get; set; }
3332

33+
ContentView AnnotationView { get; set; }
34+
IViewAnnotationController ViewAnnotationController { get; }
35+
3436
IAnnotationController AnnotationController { get; }
3537

3638
IMapFeatureQueryable QueryManager { get; }
@@ -39,7 +41,6 @@ public partial interface IMapboxView : IView
3941

4042
ILocationComponentPlugin LocationComponent { get; }
4143
}
42-
4344
partial interface IMapboxView
4445
{
4546
event EventHandler MapReady;
@@ -54,7 +55,7 @@ partial interface IMapboxView
5455
event EventHandler<MapTappedEventArgs> MapTapped;
5556
ICommand Command { get; }
5657

57-
event EventHandler<CameraChangedEventArgs> CameraChanged;
58+
event EventHandler<Camera.CameraChangedEventArgs> CameraChanged;
5859
ICommand CameraChangedCommand { get; }
5960

6061
event EventHandler<Viewport.ViewportStatusChangedEventArgs> ViewportStatusChanged;
@@ -68,85 +69,7 @@ partial interface IMapboxView
6869
ICommand RotatingCommand { get; }
6970
}
7071

71-
public interface IAnnotationController
72-
{
73-
IPolygonAnnotationManager CreatePolygonAnnotationManager(string id, LayerPosition layerPosition);
74-
ICircleAnnotationManager CreateCircleAnnotationManager(string id, LayerPosition layerPosition);
75-
IPointAnnotationManager CreatePointAnnotationManager(string id, LayerPosition layerPosition, ClusterOptions clusterOptions = null);
76-
IPolylineAnnotationManager CreatePolylineAnnotationManager(string id, LayerPosition layerPosition);
77-
}
78-
7972
public interface IMapFeatureQueryable
8073
{
8174
Task<IEnumerable<QueriedRenderedFeature>> QueryRenderedFeaturesWith(ScreenPosition point, RenderedQueryOptions options);
8275
}
83-
84-
public interface IMapboxController
85-
{
86-
IPosition GetMapPosition(ScreenPosition position);
87-
CoordinateBounds GetCoordinateBoundsForCamera(CameraOptions cameraOptions);
88-
ScreenPosition GetScreenPosition(IPosition position);
89-
CameraOptions? CameraForCoordinates(
90-
IEnumerable<IPosition> coordinates,
91-
CameraOptions? cameraOptions = default,
92-
Thickness? coordinatesPadding = default,
93-
double? maxZoom = default,
94-
ScreenPosition? offset = default
95-
);
96-
void CameraForCoordinates(
97-
IEnumerable<IPosition> coordinates,
98-
Action<CameraOptions?> completion,
99-
CameraOptions? cameraOptions = default,
100-
Thickness? coordinatesPadding = default,
101-
double? maxZoom = default,
102-
ScreenPosition? offset = default
103-
);
104-
void SetSourcePropertyFor<T>(string sourceId, string propertyName, T value, Action<Exception> completion = default);
105-
void SetLayerPropertyFor<T>(string layerId, string propertyName, T value, Action<Exception> completion = default);
106-
}
107-
108-
public class MapTappedEventArgs : EventArgs
109-
{
110-
public MapTappedPosition Position { get; }
111-
112-
public MapTappedEventArgs(MapTappedPosition position)
113-
{
114-
Position = position;
115-
}
116-
}
117-
public class CameraChangedEventArgs : EventArgs
118-
{
119-
public CameraChangedEventArgs(CameraOptions options)
120-
{
121-
Options = options;
122-
}
123-
124-
public CameraOptions Options { get; }
125-
}
126-
public class IndicatorAccuracyRadiusChangedEventArgs : EventArgs
127-
{
128-
public IndicatorAccuracyRadiusChangedEventArgs(double radius)
129-
{
130-
Radius = radius;
131-
}
132-
133-
public double Radius { get; }
134-
}
135-
public class IndicatorBearingChangedEventArgs : EventArgs
136-
{
137-
public IndicatorBearingChangedEventArgs(double bearing)
138-
{
139-
Bearing = bearing;
140-
}
141-
142-
public double Bearing { get; }
143-
}
144-
public class IndicatorPositionChangedEventArgs : EventArgs
145-
{
146-
public IndicatorPositionChangedEventArgs(IPosition position)
147-
{
148-
Position = position;
149-
}
150-
151-
public IPosition Position { get; }
152-
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MapboxMaui;
2+
3+
public class IndicatorAccuracyRadiusChangedEventArgs : EventArgs
4+
{
5+
public IndicatorAccuracyRadiusChangedEventArgs(double radius)
6+
{
7+
Radius = radius;
8+
}
9+
10+
public double Radius { get; }
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MapboxMaui;
2+
3+
public class IndicatorBearingChangedEventArgs : EventArgs
4+
{
5+
public IndicatorBearingChangedEventArgs(double bearing)
6+
{
7+
Bearing = bearing;
8+
}
9+
10+
public double Bearing { get; }
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MapboxMaui;
2+
3+
public class IndicatorPositionChangedEventArgs : EventArgs
4+
{
5+
public IndicatorPositionChangedEventArgs(IPosition position)
6+
{
7+
Position = position;
8+
}
9+
10+
public IPosition Position { get; }
11+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MapboxMaui;
2+
3+
public class MapTappedEventArgs : EventArgs
4+
{
5+
public MapTappedPosition Position { get; }
6+
7+
public MapTappedEventArgs(MapTappedPosition position)
8+
{
9+
Position = position;
10+
}
11+
}

0 commit comments

Comments
 (0)