Paint RadMap

2 Answers 102 Views
Map
Ammar
Top achievements
Rank 1
Ammar asked on 05 Jul 2021, 10:02 AM

I need to draw 2,520 square shapes on a RadMap. I have the  locations (let, lng) of each square. They should have different colors (as in the attached image)

 When I use polygons to draw the squares, I face 2 issues:

(1) it takes very long time to complete the drawing of 2520 squares,

(2) I run out of memory as this process takes over 3 GB of memory.

Is there a better way to do this task?

 

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 06 Jul 2021, 08:16 AM

Hello Armar,

In RadMap we are painting the objects using GDI+ and the Graphics class. I'm afraid that in this particular scenario, you might be hitting a limitation of the graphics engine. 

The rectangles seen in the screenshot, however, seem possible to render. I am assuming that you might be having hundreds or even thousands of neighboring rectangles having the same color. For that case, you can consider removing the unnecessary vertices and creating one big shape. This way you could reduce the number of objects and improve the performance and memory consumption.

I hope this will help. Let me know if you have further questions.

Regards,
Hristo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ammar
Top achievements
Rank 1
commented on 07 Jul 2021, 02:25 PM

Thanks Hristo.
Unfortunately, this would not solve the problem because the neighboring pints are not often have the same color.
Is it possible to change the MapPoint shape from circle to square?
0
Hristo
Telerik team
answered on 08 Jul 2021, 04:04 PM

Hi Ammar, 

Sorry to hear that combining the rectangles is not suitable for your actual case. Please consider, however, that even if not all shapes get optimized, excluding the unnecessary vertices could still improve the performance. This will depend on the number of the affected shapes.

As to the MapPoint question, it's possible to use a rectangle and to paint it instead of the default circle. For the purpose, you will need to create a custom MapPoint class and to override the CreateVisualElementInfo method: 
public class MapRectPoint : MapPoint
{
	public MapRectPoint(PointG location)
        : base(location, new Size(8, 8))
    { }

    protected override MapVisualElementInfo CreateVisualElementInfo(IMapViewport viewport)
    {
        GraphicsPath path = new GraphicsPath();

        RectangleL drawRect = new RectangleL(0 - this.Size.Width / 2, 0 - this.Size.Height / 2, this.Size.Width, this.Size.Height);
        path.AddRectangle(drawRect);

        PointL offset = MapTileSystemHelper.LatLongToPixelXY(this.Location, viewport.ZoomLevel);

        return new MapVisualElementInfo(path, offset);
    }
}

Additionally, you can also override the point's Paint method and completely customize how the shape is painted.

Regards,
Hristo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Map
Asked by
Ammar
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or