This is a migrated thread and some comments may be shown as answers.

Draw square throwing exception at method MapRectangle.SetShapeParameters

1 Answer 28 Views
Map
This is a migrated thread and some comments may be shown as answers.
DMC Helpdesk
Top achievements
Rank 1
DMC Helpdesk asked on 22 Dec 2011, 01:16 PM
Hi,

I am trying to draw a sequare using the MapRectangle control.The sample I found at this post (http://www.telerik.com/community/forums/wpf/map/draw-square.aspx) is throwing exception at the highlighted line:

private void SetShapeParameters()
        {
            if (this.MapControl != null)
            {
                Rectangle rect = this.Shape as Rectangle;
 
                Size size = this.MapCanvas.GetPixelSize(this.Location, this.RadiusX, this.RadiusY);
                if (!double.IsNaN(size.Width) && !double.IsInfinity(size.Width))
                {
                    rect.RadiusX = size.Width;
                }
 
                if (!double.IsNaN(size.Height) && !double.IsInfinity(size.Height))
                {
                    rect.RadiusY = size.Height;
                }
            }
        }

The exception is "Object reference not set to an instance of an object" and it is because this.MapCanvas is null.

Any help will be highly appreciated.

Madani

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 23 Dec 2011, 04:06 PM
Hi,

We are aware of this problem in older versions of RadControls (2011 Q1 or Q2) and it has already been fixed.

In addition, the sample you use was created for older than 2011 Q1 version of map control and it contains unnecessary functionality. I have attached a modified solution which does not contain it. Also it implements a correct order for drawing rectangle and it does not cause the exception.

All the best,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Map
Asked by
DMC Helpdesk
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or