Updating editable GoogleMapsPolygon doesn't work

Hello there,

I am converting my WebGMaps to FNCMaps. I have some polygons that are editable that I want to store in my DB.

Somehow the polygons need to be updated before reading the new positions. With webGMaps I did that by the following line:

WebGMaps1.GetModifiedMapPolygon(WebGMaps1.Polygons[0].Polygon);

There are some examples of updating rectangles in the documentation.

procedure TForm1.TMSFNCGoogleMaps1PolyElementEditEnd(Sender: TObject;
AEventData: TTMSFNCMapsEventData);
begin
if assigned (AEventData.PolyElement) then
begin
if (AEventData.PolyElement is TTMSFNCGoogleMapsRectangle) then
(AEventData.PolyElement as TTMSFNCGoogleMapsRectangle).Bounds.JSON:= AEventData.CustomData;
end;
end;

So in my logic I made it like this for the polygons but as you guessed it doesn't work.

procedure TfrmZone2.MapsPolyElementEditEnd(Sender: TObject; AEventData: TTMSFNCMapsEventData);
begin
if Assigned(AEventData.PolyElement) then
begin
if (AEventData.PolyElement is TTMSFNCGoogleMapsPolygon) then
begin
(AEventData.PolyElement as TTMSFNCGoogleMapsPolygon).Coordinates.JSON := AEventData.CustomData;
end;
end;
end;

What is the correct way?

Thanks in advance!

Attached is a sample that demonstrates this

Sample.zip (93.5 KB)

What a quick answer Peter! Thank you very very much. I only had to change TTMSFNCGoogleMapsPolyline into TTMSFNCGoogleMapsPolygon and it is done and dusted. Happy weekend!

1 Like

Thanks for the kind response!

1 Like

Hi Peter,

Sorry for bothering you it worked fine. But now after adding some stuff (screen centre etc) , when I drag a point the polygon disappears and they all move to the statue of liberty (no joke).

Any idea?

Found it (weird stuff btw). In the implementation section:

uses Vcl.TMSFNCMapsCommonTypes;

I moved that to the interface. Think it mixed up some datatypes.

Happy weekend!

1 Like

Thanks for the followup!

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.