Topic: Request/Load/Create Buildings

Hi,

I'd like to limit the number of OSM buildings according to the distance between the building and a player on the ground.
The buildings should dynamically be loaded and disposed when the player moves.

I did a first naive implementation by altering a line in the OnlineMapsBuildings script:

building = OnlineMapsBuildingBuiltIn.Create(this, data.way, data.nodes);

if (building != null && Vector3.Distance(Player.transform.position, building.transform.position) < 200)
{
    building.LoadMeta(data.way);
    if (OnBuildingCreated != null) OnBuildingCreated(building);
    unusedBuildings.Add(data.way.id, building);
}

But I'd like to ask how I can make such a functionality work the "proper" way.  Maybe there's something in your API that I missed.
Changing the zoom level and therefore limit the number of buildings as a whole is not an option for several reasons.

Thanks in advance.

Re: Request/Load/Create Buildings

Hello.

In Online Maps v2.3 beta, we have added a few API, which is will help control the buildings:
1. OnlineMapsBuildings.maxBuilding - The maximum number of buildings.
2. OnlineMapsBuildings.maxActiveBuildings - The maximum number of active (visible) buildings.
3. OnlineMapsBuildings.OnCreateBuilding - This event is triggered before create a building.
Return TRUE - if you want to create this building, FALSE - avoid creating this building.
4. OnlineMapsBuildings.OnPrepareRequest - This event is called when creating a request to OSM Overpass API.
This is useful if you want to limit / expand request. For example, you want to get information only on some types of buildings.

Example of using attached.

Please update Online Maps through the built-in update (Component / Infinity Code / Online Maps / Check Updates) to the latest beta version.

Post's attachments

Attachment icon BuildingCustomRequestExample.cs 1.45 kb, 864 downloads since 2015-12-03 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.