Topic: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

So my app has to draw line behind a marker when the marker is constantly moving, so new points are added to the line segments, I'm currently using

lineSegment?.Dispose();
lineSegment?.DestroyInstance();
lineSegment = new OnlineMapsDrawingLine(listPoints, Color.red, 2); 

and every time the function call is happens so i get new points and draw new lines from scratch, I'm guess I've done something horribly wrong here cause the garbage collection is through the roof, is there a better way to handle the addition of new points in an existing line segment or how to handle this scenario, I'm using online maps v3 can provide more details if necessary.

Re: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

Hi.

In Online Maps v3, the line keeps a reference to the original list, and you don't need to constantly destroy and recreate the line.
The map will automatically see the changes.
You only need to cause the map to redraw.

In Online Maps v4, for performance reasons, the line no longer keeps a reference to the original list, and you need to call the SetPoints method when points change.

Kind Regards,
Infinity Code Team.

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

Re: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

Thanks for the help, its working now, thank again have a nice day

Re: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

@Alex Vertax https://forum.infinity-code.com/viewtop … 9837#p9837 thanks for the solution it works nice, i ran a test by making the app run for like 8hours, the vertex count went up to 89k (line points passed 35k) the apps FPS dropped after this from 30fps to 10fps, but when i disabled the OnlineMapsDrawingElementManager script the fps climbed back up(not the lines), is there any optimization that i can do for this kind of drops ?

Re: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

Drawing API is very heavy, and if you have 35k points, you need to help the map.
For example, you can optimize the points in your list by removing those that are on the same line or the distance between them is less than some threshold.
You can also divide the line into chunks (e.g. 100 points each), calculate the chunk's bounding box, and if it does not overlap with the map, disable the drawing element.

Kind Regards,
Infinity Code Team.

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

Re: Drawing lines using "OnlineMapsDrawingLine" constantly how to handle ?

Thanks for the update, will look into you suggestion.