DrawPolygon and AddLabel problems

Nov 22, 2012 at 9:23 AM

Hellow.

I am using MapWinGIS with Embarcadero RAD Studio C++ XE (Borland).

I have a problems when I tried to draw polygon on the map and add label.

Here is the code of polygon drawing:

  mwgMap* Map = Form1->mwgMap1;
  Map->CursorMode = Mapwingis_tlb::tkCursorMode::cmNone;
  Map->ClearDrawings();
  int dlh = Map->NewDrawing(Mapwingis_tlb::tkDrawReferenceList::dlSpatiallyReferencedList);
  double* x;
  double* y;
  int n = 3;
  x = new double[n];
  y = new double[n];
  x[0] = 0.0; x[1] = 1.0; x[2] = 1.0;
  y[0] = 0.0; y[1] = 0.0; y[2] = 1.0;

//  Map->DrawWidePolygonEx(dlh, x, y, n, 0, 0, 2); //This is not working

Here the problems is how can I set parameters x and y in c++. I was create arrays of doubles, but RAD Studio wants "tagVARIANT*". How can I convert?

I found in the internet that other programmers have the same problems but I am not found decision.

Function AddLabel breaks the program by exception:

Project MapWinGISTest.exe raised exception class EAccessViolation with message 'Access violation at address 7C80A2F0 in module 'KERNEL32.dll'. Read of address 00CA1000'.

The code is:

  mwgMap* Map = Form1->mwgMap1;
  Map->CursorMode = Mapwingis_tlb::tkCursorMode::cmNone;
  Map->ClearDrawings();
  int dlh = Map->NewDrawing(Mapwingis_tlb::tkDrawReferenceList::dlSpatiallyReferencedList);
  AnsiString Str = "Draw this on the map!";
  wchar_t* text = AnsiToWchar_t(Str);
  Map->AddLabel(dlh, text, 0, 1.0, 1.0, Mapwingis_tlb::tkHJustification::hjLeft);

AnsiToWchar_t is my convertion function between Borland C++ string types. It works correct. In my case RAD Studio wants "text" argument as wchar_t* type. In debuging I saw that convertion of string is correct, but I have not idea why the function crashes.

Thank you in advance.