Bug Report T125926
Visible to All Users

The "Invalid operation in GDI+ (code: 2)" exception occurs when painting a map path that includes a segment formed by exactly two geographical points

created 11 years ago

Hello,

I'm trying to show a path on a TdxMapControl with an OpenStreetMap layer. I use the following code:

C#
procedure TForm2.Button1Click(Sender: TObject); var AItemLayer : TdxMapItemLayer; APath : TdxMapPath; ASegment : TdxMapPathSegment; APoint : TdxMapControlGeoPointItem; begin //dxMapControl1.Layers.BeginUpdate; AItemLayer := dxMapControl1.AddItemLayer; AItemLayer.ItemStyle.BorderColor := dxColorToAlphaColor(clBlue); APath := TdxMapPath(AItemLayer.AddItem(TdxMapPath)); APath.Style.BorderColor := dxColorToAlphaColor(clBlue); //APath.Segments.BeginUpdate; ASegment := APath.Segments.Add; //ASegment.GeoPoints.BeginUpdate; APoint := ASegment.GeoPoints.Add; APoint.Latitude := 52; APoint.Longitude := 8; APoint := ASegment.GeoPoints.Add; APoint.Latitude := 51; APoint.Longitude := 7; //ASegment.GeoPoints.EndUpdate; //APath.Segments.EndUpdate; //dxMapControl1.Layers.EndUpdate; end;

After pressing "Button1" nothing happens. If I try to scroll the map I get an error "Invalid operation in GDI+ (Code: 2)". It makes no difference if I uses BeginUpdate/EndUpdate. Unfortunately the documentation of the MapControl is not available, yet. So i'm not sure if the code is realy right.

If It try the same with the design time editor i get the GDI error immediately after starting the applictaion.

Best regards

Philipp

Comments (1)
DevExpress Support Team 11 years ago

    Hello,

    I have converted this question to a bug report. As a temporary workaround, add one more point to the Segment geopoints collection or use the TdxMapPolyline element instead.

    Answers approved by DevExpress Support

    created 11 years ago

    We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

    Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.