@@ -62,13 +62,28 @@ public void SetUpPlacement(AbstractMap map)
62
62
}
63
63
/// <summary>
64
64
/// Abstract map.
65
- /// This is the main monobehavior which controls the map. It controls the visualization of map data.
66
- /// Abstract map encapsulates the image, terrain and vector sources and provides a centralized interface to control the visualization of the map.
65
+ /// This is the main monobehavior which controls the map. It controls the visualization of map data.
66
+ /// Abstract map encapsulates the image, terrain and vector sources and provides a centralized interface to control the visualization of the map.
67
67
/// </summary>
68
68
public class AbstractMap : MonoBehaviour , IMap
69
69
{
70
+ /// <summary>
71
+ /// Setting to trigger map initialization in Unity's Start method.
72
+ /// if set to false, Initialize method should be called explicitly to initialize the map.
73
+ /// </summary>
70
74
[ SerializeField ]
71
75
private bool _initializeOnStart = true ;
76
+ public bool InitializeOnStart
77
+ {
78
+ get
79
+ {
80
+ return _initializeOnStart ;
81
+ }
82
+ set
83
+ {
84
+ _initializeOnStart = value ;
85
+ }
86
+ }
72
87
/// <summary>
73
88
/// The map options.
74
89
/// Options to control the behaviour of the map like location,extent, scale and placement.
@@ -87,7 +102,7 @@ public MapOptions Options
87
102
}
88
103
}
89
104
/// <summary>
90
- /// Options to control the imagery component of the map.
105
+ /// Options to control the imagery component of the map.
91
106
/// </summary>
92
107
[ SerializeField ]
93
108
ImageryLayer _imagery = new ImageryLayer ( ) ;
@@ -114,8 +129,8 @@ public TerrainLayer Terrain
114
129
}
115
130
/// <summary>
116
131
/// The vector data.
117
- /// Options to control the vector data component of the map.
118
- /// Adds a vector source and visualizers to define the rendering behaviour of vector data layers.
132
+ /// Options to control the vector data component of the map.
133
+ /// Adds a vector source and visualizers to define the rendering behaviour of vector data layers.
119
134
/// </summary>
120
135
[ SerializeField ]
121
136
VectorLayer _vectorData = new VectorLayer ( ) ;
@@ -188,8 +203,8 @@ public int AbsoluteZoom
188
203
189
204
protected int _initialZoom ;
190
205
/// <summary>
191
- /// Gets the initial zoom at which the map was initialized.
192
- /// This parameter is useful in calculating the scale of the tiles and the map.
206
+ /// Gets the initial zoom at which the map was initialized.
207
+ /// This parameter is useful in calculating the scale of the tiles and the map.
193
208
/// </summary>
194
209
/// <value>The initial zoom.</value>
195
210
public int InitialZoom
@@ -233,8 +248,8 @@ public float WorldRelativeScale
233
248
}
234
249
}
235
250
/// <summary>
236
- /// Gets the current zoom value of the map.
237
- /// Use <c>AbsoluteZoom</c> to get the zoom level of the tileset.
251
+ /// Gets the current zoom value of the map.
252
+ /// Use <c>AbsoluteZoom</c> to get the zoom level of the tileset.
238
253
/// <seealso cref="AbsoluteZoom"/>
239
254
/// </summary>
240
255
/// <value>The zoom.</value>
@@ -300,8 +315,8 @@ protected IEnumerator SetupAccess()
300
315
}
301
316
/// <summary>
302
317
/// Sets up map.
303
- /// This method uses the mapOptions and layer properties to setup the map to be rendered.
304
- /// Override <c>SetUpMap</c> to write custom behavior to map setup.
318
+ /// This method uses the mapOptions and layer properties to setup the map to be rendered.
319
+ /// Override <c>SetUpMap</c> to write custom behavior to map setup.
305
320
/// </summary>
306
321
protected virtual void SetUpMap ( )
307
322
{
@@ -332,7 +347,7 @@ protected virtual void SetUpMap()
332
347
if ( _options . extentOptions . extentType != MapExtentType . Custom )
333
348
{
334
349
ITileProviderOptions tileProviderOptions = _options . extentOptions . GetTileProviderOptions ( ) ;
335
- // Setup tileprovider based on type.
350
+ // Setup tileprovider based on type.
336
351
switch ( _options . extentOptions . extentType )
337
352
{
338
353
case MapExtentType . CameraBounds :
@@ -431,7 +446,7 @@ protected virtual void InitializeMap(MapOptions options)
431
446
}
432
447
/// <summary>
433
448
/// Initialize the map using the specified latLon and zoom.
434
- /// Map will automatically get initialized in the <c>Start</c> method.
449
+ /// Map will automatically get initialized in the <c>Start</c> method.
435
450
/// Use this method to explicitly initialize the map and disable intialize on <c>Start</c>
436
451
/// </summary>
437
452
/// <returns>The initialize.</returns>
@@ -451,9 +466,9 @@ public virtual void Initialize(Vector2d latLon, int zoom)
451
466
}
452
467
/// <summary>
453
468
/// Updates the map.
454
- /// Use this method to update the location of the map.
455
- /// Update method should be used when panning, zooming or changing location of the map.
456
- /// This method avoid startup delays that might occur on re-initializing the map.
469
+ /// Use this method to update the location of the map.
470
+ /// Update method should be used when panning, zooming or changing location of the map.
471
+ /// This method avoid startup delays that might occur on re-initializing the map.
457
472
/// </summary>
458
473
/// <param name="latLon">LatitudeLongitude.</param>
459
474
/// <param name="zoom">Zoom level.</param>
@@ -473,7 +488,7 @@ public virtual void UpdateMap(Vector2d latLon, float zoom)
473
488
xDelta = xDelta > 0 ? Mathd . Min ( xDelta , Mapbox . Utils . Constants . LatitudeMax ) : Mathd . Max ( xDelta , - Mapbox . Utils . Constants . LatitudeMax ) ;
474
489
zDelta = zDelta > 0 ? Mathd . Min ( zDelta , Mapbox . Utils . Constants . LongitudeMax ) : Mathd . Max ( zDelta , - Mapbox . Utils . Constants . LongitudeMax ) ;
475
490
476
- //Set Center in Latitude Longitude and Mercator.
491
+ //Set Center in Latitude Longitude and Mercator.
477
492
SetCenterLatitudeLongitude ( new Vector2d ( xDelta , zDelta ) ) ;
478
493
Options . scalingOptions . scalingStrategy . SetUpScaling ( this ) ;
479
494
@@ -489,7 +504,7 @@ public virtual void UpdateMap(Vector2d latLon, float zoom)
489
504
}
490
505
/// <summary>
491
506
/// Resets the map.
492
- /// Use this method to reset the map to and reset all parameters.
507
+ /// Use this method to reset the map to and reset all parameters.
493
508
/// </summary>
494
509
public void ResetMap ( )
495
510
{
@@ -545,7 +560,7 @@ protected void SendInitialized()
545
560
546
561
internal Vector3 GeoToWorldPositionXZ ( Vector2d latitudeLongitude )
547
562
{
548
- // For quadtree implementation of the map, the map scale needs to be compensated for.
563
+ // For quadtree implementation of the map, the map scale needs to be compensated for.
549
564
var scaleFactor = Mathf . Pow ( 2 , ( InitialZoom - AbsoluteZoom ) ) ;
550
565
var worldPos = Conversions . GeoToWorldPosition ( latitudeLongitude , CenterMercator , WorldRelativeScale * scaleFactor ) . ToVector3xz ( ) ;
551
566
return Root . TransformPoint ( worldPos ) ;
@@ -570,7 +585,7 @@ protected virtual float QueryElevationAtInternal(Vector2d latlong, out float til
570
585
571
586
}
572
587
/// <summary>
573
- /// Converts a latitude longitude into map space position.
588
+ /// Converts a latitude longitude into map space position.
574
589
/// </summary>
575
590
/// <returns>Position in map space.</returns>
576
591
/// <param name="latitudeLongitude">Latitude longitude.</param>
@@ -589,13 +604,13 @@ public virtual Vector3 GeoToWorldPosition(Vector2d latitudeLongitude, bool query
589
604
return worldPos ;
590
605
}
591
606
/// <summary>
592
- /// Converts a position in map space into a laitude longitude.
607
+ /// Converts a position in map space into a laitude longitude.
593
608
/// </summary>
594
609
/// <returns>Position in Latitude longitude.</returns>
595
610
/// <param name="realworldPoint">Realworld point.</param>
596
611
public virtual Vector2d WorldToGeoPosition ( Vector3 realworldPoint )
597
612
{
598
- // For quadtree implementation of the map, the map scale needs to be compensated for.
613
+ // For quadtree implementation of the map, the map scale needs to be compensated for.
599
614
var scaleFactor = Mathf . Pow ( 2 , ( InitialZoom - AbsoluteZoom ) ) ;
600
615
601
616
return ( Root . InverseTransformPoint ( realworldPoint ) ) . GetGeoPosition ( CenterMercator , WorldRelativeScale * scaleFactor ) ;
0 commit comments