Topic: Online Maps Polygon Performance Issue

Like you suggested in : http://forum.infinity-code.com/viewtopic.php?id=971

I am using onlineMapsDrawing api to draw elements, now I am drawing the border of the map as polygon (16821 verticles), which is quite a lot.

I did notice in case of using tileSet (which I am) there is this code :

public override void UpdateControl()
    {
        base.UpdateControl();

        if (OnlineMapsTile.tiles == null) return;

        UpdateMapMesh();

        if (OnlineMapsDrawingElementManager.CountItems > 0)
        {
            if (drawingMode == OnlineMapsTilesetDrawingMode.meshes)
            {
                if (drawingsGameObject == null) InitDrawingsMesh();
                int index = 0;
                foreach (OnlineMapsDrawingElement drawingElement in OnlineMapsDrawingElementManager.instance)
                {
                    drawingElement.DrawOnTileset(this, index++);
                }
            }
        }

        if (OnDrawMarkers != null) OnDrawMarkers();
    

Which in my guess is source of my performance issues on mobile device.

I did tried to override the 'OnlineMapsDrawingElement' create my own etc, but wasn't able to properly move it with movment of the map (added 'OnChangePosition', and 'OnChangeZoom' listeners, then tried .GetWorldPosition etc, but I didn't had reference point since you recreate polygons each time the map need to be updated).

My question is, Is there any reason why You are not creating polygon just once and then move it with the map and scale it properly ? In my opinion this would greatly increase performance?

Or am I mistaken and I am missing something ?

While I am able to create polygon on my own (later on I might write my own code to actually make png out of all verticles since its not dynamicaly loaded data anyway and move it on the map) I am still unable to detect how should I move the poly or by how much should I scale it to have correct behavior.

Re: Online Maps Polygon Performance Issue

Hello.

You started to explain the problem from the wrong side.
I do not know what and how you are doing and why you have a polygon with 17k vertices.

Please, first explain what you want to do and show your code that you are using.
I'm 99% sure that if you have a polygon with 17k vertices, you are moving in the wrong direction.

Kind Regards,
Infinity Code Team.

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

Re: Online Maps Polygon Performance Issue

I download the JSON (had to go to page source and copy the data from there actually) that generates this map ( for example ) :
http://umap.openstreetmap.fr/en/map/les … .025/4.839

and the borders of the region sums up to 17k verticles (the border of the "region").

All other elements aren't problematic ( I am just creating them as markers with different texture with parsing the JSON i got from the website).

Here it is how it looks with the border generated from 17k verticles, which is great until I touch/move the map, the fps is around 5-10 (thats what it feels like).
PunBB bbcode test

Thanks in advance now I hope you know what I wanted to achive and why I use 17k verticles.

Re: Online Maps Polygon Performance Issue

Using Drawing API for a large number of points is very expensive, because it has a lot of complicated calculations.
Map need a little help from you.

How to do it:
Way 1: Reduce the number of points at low zoom to increase performance when there are many points in the map view.
For a larger zoom, most of the points are outside the map view, and they are clipped. It works fast.

Way 2: Draw complex lines in some other way, for example, LineRenderer or GL.
This way can be combined with the first way.

Examples are attached.

Post's attachments

Attachment icon DrawComplexPoly.cs 2.9 kb, 93 downloads since 2018-11-28 

Attachment icon SimplifyPoly.cs 2.16 kb, 98 downloads since 2018-11-28 

Kind Regards,
Infinity Code Team.

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