1 (edited by SweetTooth 2017-05-31 12:13:59)

Topic: How to visualize quads (tileset map case)?

Hello

Can you please tell me, how can I visualize quads on the map via simple cube meshes?

I tried the following algorythm:

1. converted current quad to tile coordinates
2. subtracted Vector2(0.5f, 0.5f) from it to get tile center (not sure about y, maybe it should be inverted)
3. converted tile center coordinates to geographic coordinates
4. used the OnlineMapsTileSetControl.instance.GetWorldPosition() method to get the position and calculated scale

It works, but looks awful, because when map is being dragged, the calculated world position always differs and it makes the mesh which shows quad bounds to constantly reposition... Is it possible to mitigate this effect somehow?

Please help...

Re: How to visualize quads (tileset map case)?

Actually the problem is caused by scale calculation - I use logic from the DrawCircleWithRadius example:

        OnlineMaps api = OnlineMaps.instance;

        Vector2 distance = OnlineMapsUtils.DistanceBetweenPoints(api.topLeftPosition, api.bottomRightPosition);

        float scaleX = diameterInKM / distance.x * api.tilesetSize.x;
        float scaleY = diameterInKM / distance.y * api.tilesetSize.y;
        float scale = (scaleX + scaleY) / 2;

        circle.transform.localScale = new Vector3(scale, sizeY, scale);

and if I try to clamp it on zoom level 17+, it solves the issue, however this makes quad visualization incorrect... What should I do?

Re: How to visualize quads (tileset map case)?

Actually nevermind, the optimal solution seems to calculate all 4 corners and create lines via mesh with clamped scale