in SupportingScripts/Runtime/Scripts/MapRenderer/MapRenderer.cs [358:465]
private void UpdateChildrenMapPins()
{
Profiler.BeginSample("UpdateChildrenMapPins");
_mapPinsInView.Clear();
// Get all the direct descendant MapPins of this GameObject that are in view.
{
if (_checkChildMapPins)
{
_currentChildrenMapPins.Clear();
var currentChildrenMapPins = GetComponentsInChildren<MapPin>(true);
foreach (var currentChildMapPin in currentChildrenMapPins)
{
if (currentChildMapPin.transform.parent == transform)
{
_currentChildrenMapPins.Add(currentChildMapPin);
}
}
// Add any new MapPin children.
foreach (var mapPin in _currentChildrenMapPins)
{
if (_mapPinChildrenSet.Add(mapPin))
{
// This is a new MapPin. Deactivate until it's position has been calculated.
mapPin.gameObject.SetActive(false);
}
}
// Remove any MapPins that are no longer children or have been disabled.
{
_mapPinChildrenToRemove.Clear();
foreach (var existingChildMapPin in _mapPinChildrenSet)
{
if (!_currentChildrenMapPins.Contains(existingChildMapPin))
{
_mapPinChildrenToRemove.Add(existingChildMapPin);
}
}
foreach (var mapPinChildToRemove in _mapPinChildrenToRemove)
{
_mapPinChildrenSet.Remove(mapPinChildToRemove);
}
}
_currentChildrenMapPins.Clear();
_mapPinChildrenToRemove.Clear();
_checkChildMapPins = false;
}
// Get the MapPins in view.
if (_mapPinChildrenSet.Count > 0)
{
if (MapShape == MapShape.Block)
{
var mercatorBoundingBox = MercatorBoundingBox;
foreach (var mapPin in _mapPinChildrenSet)
{
if (mapPin.ShowOutsideMapBounds || mercatorBoundingBox.Intersects(mapPin.Location))
{
_mapPinsInView.Add(mapPin);
}
}
}
else // Cylinder
{
var mercatorBoundingCircle = MercatorBoundingCircle;
foreach (var mapPin in _mapPinChildrenSet)
{
if (mapPin.ShowOutsideMapBounds || mercatorBoundingCircle.Intersects(mapPin.MercatorCoordinate))
{
_mapPinsInView.Add(mapPin);
}
}
}
}
}
TrackAndPositionPinnables(_mapPinsInView);
// Disable any MapPins that were in the last view but is not the current view.
{
foreach (var lastMapPinInView in _lastMapPinsInView)
{
if (lastMapPinInView != null && !_mapPinsInView.Contains(lastMapPinInView))
{
UntrackPinnable(lastMapPinInView);
lastMapPinInView.gameObject.SetActive(false);
}
}
_lastMapPinsInView.Clear();
_lastMapPinsInView.AddRange(_mapPinsInView);
}
MapPin.SynchronizeLayers(_mapPinsInView, this);
MapPin.UpdateScales(_mapPinsInView, this);
// Ensure the MapPins that have had their positions computed have been enabled.
foreach (var mapPinInView in _mapPinsInView)
{
mapPinInView.gameObject.SetActive(mapPinInView.HasBeenFullyPositioned && mapPinInView.enabled);
}
Profiler.EndSample();
}