Search code examples
delphidelphi-xe7gmlib

GMLib move existing marker


Using GMLib on Delphi XE-7, I'm trying to move existing marker to new position, I have created only one marker on the map and tried using code below as a test to move it.

procedure TfrmMapClient.GMMap1Click(Sender: TObject; LatLng: TLatLng; X, Y:   Double);
begin

mcnt := gmmarker1.count;
gmmarker1.Items[0].Position:= LatLng;

end;

but getting Exception Access Violation. Any help much appreciated


Solution

  • Try with

    gmmarker1.Items[0].Position.Assign(LatLng);
    

    or assigning individual properties

    gmmarker1.Items[0].Position.Lat := LatLng.Lat;
    gmmarker1.Items[0].Position.Lng := LatLng.Lng;