9
9
10
10
namespace Mapbox . BaseModule . Map
11
11
{
12
+ /// <summary>
13
+ /// The primary object responsible for controlling and rendering the map.
14
+ /// </summary>
15
+ /// <remarks>
16
+ /// - <see cref="MapInformation"/>: Contains information about the map location,
17
+ /// detail level, and basic camera controls.
18
+ /// - <see cref="MapVisualizer"/>: Handles styling and visualization of the specified location.
19
+ /// - <see cref="MapService"/>: Manages interactions with the Mapbox API and data handling.
20
+ /// </remarks>
12
21
[ Serializable ]
13
22
public sealed class MapboxMap
14
23
{
@@ -28,6 +37,10 @@ public MapboxMap(IMapInformation information, UnityContext unityContext, MapServ
28
37
MapService = mapMapService ;
29
38
}
30
39
40
+ /// <summary>
41
+ /// Initialization method which organizes caches and object pool craeting, meta data loading etc.
42
+ /// </summary>
43
+ /// <returns></returns>
31
44
public IEnumerator Initialize ( )
32
45
{
33
46
if ( Status != InitializationStatus . WaitingForInitialization )
@@ -40,15 +53,30 @@ public IEnumerator Initialize()
40
53
41
54
Status = InitializationStatus . Initialized ;
42
55
Initialized ( ) ;
43
-
44
56
}
45
57
58
+ /// <summary>
59
+ /// Map update method, which we currently use per-frame, to recalculate the tile cover and run map visualizer on it.
60
+ /// </summary>
46
61
public void MapUpdated ( )
47
62
{
48
63
MapService . TileCover ( MapInformation , TileCover ) ;
49
64
MapVisualizer . Load ( TileCover ) ;
50
65
}
51
66
67
+ /// <summary>
68
+ /// Provides a controlled method for jumping to specific locations on the map.
69
+ /// Unlike standard frame-by-frame map updates, this method ensures precise
70
+ /// control over the transition process.
71
+ /// </summary>
72
+ /// <param name="callback">An optional callback method to execute upon completion.</param>
73
+ /// <remarks>
74
+ /// - Uses the location already in the settings, useful for initial map load then runtime location changes.
75
+ /// - Triggers events at the start and end of the loading process, useful for showing
76
+ /// or hiding a loading screen.
77
+ /// - Suspends per-frame map updates during the loading phase and resumes them
78
+ /// once loading is complete.
79
+ /// </remarks>
52
80
public void LoadMapView ( Action callback )
53
81
{
54
82
Status = InitializationStatus . LoadingView ;
@@ -64,11 +92,25 @@ public void LoadMapView(Action callback)
64
92
} ) ) ;
65
93
}
66
94
67
- public void LoadMapView ( Action callback , LatitudeLongitude coordinates )
95
+ /// <summary>
96
+ /// Provides a controlled method for jumping to specific locations on the map.
97
+ /// Unlike standard frame-by-frame map updates, this method ensures precise
98
+ /// control over the transition process.
99
+ /// </summary>
100
+ /// <param name="targetLocation">The destination coordinates as a <see cref="LatitudeLongitude"/> instance.</param>
101
+ /// <param name="callback">An optional callback method to execute upon completion.</param>
102
+ /// <remarks>
103
+ /// - Takes a LatitudeLongitude for new map location.
104
+ /// - Triggers events at the start and end of the loading process, useful for showing
105
+ /// or hiding a loading screen.
106
+ /// - Suspends per-frame map updates during the loading phase and resumes them
107
+ /// once loading is complete.
108
+ /// </remarks>
109
+ public void LoadMapView ( Action callback , LatitudeLongitude targetLocation )
68
110
{
69
111
Status = InitializationStatus . LoadingView ;
70
112
LoadViewStarting ( ) ;
71
- MapInformation . SetInformation ( coordinates ) ;
113
+ MapInformation . SetInformation ( targetLocation ) ;
72
114
Runnable . Instance . StartCoroutine ( LoadMapViewCoroutine ( ( ) =>
73
115
{
74
116
MapService . TileCover ( MapInformation , TileCover ) ;
@@ -80,6 +122,23 @@ public void LoadMapView(Action callback, LatitudeLongitude coordinates)
80
122
} ) ) ;
81
123
}
82
124
125
+ /// <summary>
126
+ /// Provides a controlled method for jumping to specific locations on the map.
127
+ /// Unlike standard frame-by-frame map updates, this method ensures precise
128
+ /// control over the transition process.
129
+ ///
130
+ /// </summary>
131
+ /// <param name="targetLocation">The destination coordinates as a <see cref="LatitudeLongitude"/> instance.</param>
132
+ /// <param name="callback">An optional callback method to execute upon completion.</param>
133
+ /// <returns>
134
+ /// An <see cref="IEnumerator"/> that can be used for coroutine-based execution.
135
+ /// This allows the loading process to be handled asynchronously.
136
+ /// </returns>
137
+ /// <remarks>
138
+ /// - Returns an IEnumerator to let developers create and control their own coroutine.
139
+ /// - Does not pause per-frame updates.
140
+ /// - Does not trigger start and finished events.
141
+ /// </remarks>
83
142
public IEnumerator LoadMapViewCoroutine ( Action callback )
84
143
{
85
144
var tileCover = new TileCover ( ) ;
@@ -88,6 +147,14 @@ public IEnumerator LoadMapViewCoroutine(Action callback)
88
147
callback ( ) ;
89
148
}
90
149
150
+ /// <summary>
151
+ /// Change the map core settings.
152
+ /// If the per-frame updates are enabled, new settings will be applied next frame.
153
+ /// </summary>
154
+ /// <param name="latlng">Location to show</param>
155
+ /// <param name="zoom">Zoom level of the map</param>
156
+ /// <param name="pitch">Pitch value of the camera</param>
157
+ /// <param name="bearing">Bearing value of the camera</param>
91
158
public void ChangeView ( LatitudeLongitude ? latlng = null , float ? zoom = null , float ? pitch = null , float ? bearing = null )
92
159
{
93
160
MapInformation . SetInformation ( latlng , zoom , pitch , bearing ) ;
@@ -101,10 +168,29 @@ public void OnDestroy()
101
168
102
169
public void UpdateTileCover ( ) => MapService . TileCover ( MapInformation , TileCover ) ;
103
170
171
+ /// <summary>
172
+ /// All modules are initialized, you can get&use any object and/or register to events safely.
173
+ /// </summary>
104
174
public Action Initialized = ( ) => { } ;
175
+ /// <summary>
176
+ /// Load view procedure is starting. Status is set to InitializationStatus.LoadingView and per-frame updates
177
+ /// are suspended until this procedure finishes.
178
+ /// </summary>
105
179
public Action LoadViewStarting = ( ) => { } ;
180
+ /// <summary>
181
+ /// Load view procedure is finished. Status is set to InitializationStatus.ReadyForUpdates and per-frame updates
182
+ /// will continue.
183
+ /// </summary>
106
184
public Action LoadViewCompleted = ( ) => { } ;
185
+ /// <summary>
186
+ /// Map tile finished loading with targeted detail level data. This tile isn't temporary anymore, it'll be in
187
+ /// ActiveTiles list.
188
+ /// </summary>
107
189
public Action < UnityMapTile > TileLoaded = ( tile ) => { } ;
190
+ /// <summary>
191
+ /// Map tile unloading event fires for tiles that are still in active tiles list but not in the latest tileCover.
192
+ /// UnityMapTile object attached to event will be pooled after the event call.
193
+ /// </summary>
108
194
public Action < UnityMapTile > TileUnloading = ( tile ) => { } ;
109
195
}
110
196
}
0 commit comments