First of all, starting from Online Maps v2.5.12 you can use OnlineMapsBuildings.OnAllBuildingsCreated.
How it works in the current script:
OnRequestSent is needed to get an instance of the request, and handle the situation when the map has no buildings. For example, there are no buildings in the sea, or it could just be a server error. In any case, this behavior must be handled.
The request is a private field, so you can get an instance of request only using reflection.
Online Maps take time to generate buildings.
An average of 1 millisecond per building.
But the map can contain hundreds and thousands of buildings at the same time (for example, New York or Moscow).
If you generate this number of buildings at the same time, it will just freeze your application for a few seconds.
Therefore, the map splits the generation of buildings into several frames (50 milliseconds per frame).
OnBuildingCreated will be invoked in each frame at least once.
In the frame when this action is not invoked, the generation of buildings was completed.
Kind Regards,
Infinity Code Team.
Boost your productivity a lot and immediately using
Ultimate Editor Enhancer.
Trial and non-commerce versions available.