How to Move a Marker at Runtime

Hello,

I have set the Markers on the Map Dragable:=false;
Is it Posible to Move one Marker to another Point on the Map without recreating it?
I have tried several things like mapmarkerupdate or Maprefresh/repaint after setting new long and lat values, but nothing will do the Trick.

The background is, I want the Marker to "wiggl" if it is selected in a coresponding Table on my form.

Thank you for this great tool :)

Hi,


The marker should automatically be moved to the new coordinates if you change the Latitude and/or Longitude property value. There is no further action required.
If the problem persists please provide a ready to run sample project that demonstrates the issue so I can further investigate this.
Please also provide the version of Delphi and Windows you are using.

Hi, maybe "StartMarkerBounceAnimation" and "StopMarkerBounceAnimation" is, what you are looking for...

regards

Hi,

yes "StartMarkerBounceAnimation" ist absolutley what I'am searching for
I have Searched the Forum, the documentantion, the examplecode but can't find any of that?

Can you please Help me? Where Can i Find it and use it?
I'am using WebOSMaps in the Newest Version.

Thank You

Please note that StartMarkerBounceAnimation is only available in TMS VCL WebGMaps for the Google Maps API.

Unfortunately this is unavailable in TMS VCL WebOSMaps as this is a limitation of the OpenLayers API which we have no control over.

Below is sample code to move a marker to a new location.



procedure TForm1.Button1Click(Sender: TObject);
begin
  WebOSMaps1.Markers[0].Latitude := WebOSMaps1.Markers[0].Latitude + 0.01;
  WebOSMaps1.Markers[0].Longitude := WebOSMaps1.Markers[0].Longitude + 0.01;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  WebOSMaps1.Launch;
end;

procedure TForm1.WebOSMaps1DownloadFinish(Sender: TObject);
begin
  WebOSMaps1.Markers.Clear;
  WebOSMaps1.Markers.Add(WebOSMaps1.MapOptions.DefaultLatitude, WebOSMaps1.MapOptions.DefaultLongitude, '');
  WebOSMaps1.Markers[0].Draggable := false;
end;
Hello Bart,

that is exactly what I found out so I get a bit confused about the Post from Martin.
Never than less I have done some aftermath :-) Maybe someone find it interesting. It is a Function to make a Marker Bounce uses the TMarker object from the Map.
Please note there are 2 "Bugs" I was not able to Fix jet.
1. Not realy a bug, your Application freezes for the Bounce Animation, so it would be better to Put this to an extra thread
2. If you Use MapPanTo for getting the Map to the right Position it is posible that the map is not finished showing up, so the Marker Bounces over an white Place. I was not able to get this work better. I tried the Solution with Download Finish to, but if you have 2 Marker nearly so the Map distance is realy short, the Event DownloadFinish would not be triggert.
Here is the procedure:

procedure MakeMarkerJump(lmarker: Tmarker);
var
  long, lat, jhigh: extended;
  i: Integer;
  II: Integer;
  lat2: extended;
begin
  case WebOSMaps1.MapOptions.ZoomMap of
    3:
      jhigh := 0.05;
    4:
      jhigh := 0.03;
    5:
      jhigh := 0.015;
    6:
      jhigh := 0.0075;
    7:
      jhigh := 0.005;
    8:
      jhigh := 0.002;
    9:
      jhigh := 0.00075;
    10:
      jhigh := 0.0005;
    11:
      jhigh := 0.00025;
    12:
      jhigh := 0.0001;
    13:
      jhigh := 0.00007;
    14:
      jhigh := 0.00004;
    15:
      jhigh := 0.000025;
    16:
      jhigh := 0.00001;
    17:
      jhigh := 0.000007;
    18:
      jhigh := 0.000005;
  else
    jhigh := 0.01;
  end;
  long := lmarker.Longitude;
  lat  := lmarker.Latitude;
  lat2 := lat;
  try
    for i := 3 downto 0 do
    begin
      lmarker.Latitude := lat;
      for II := 0 to i * 20 do
      begin
        lmarker.Latitude := lat + (II * jhigh);
        Application.HandleMessage;
        sleep(3);
      end;
      lat2 := lmarker.Latitude;
      for II := 0 to i * 20 do
      begin
        lmarker.Latitude := lat2 - (II * jhigh);
        Application.HandleMessage;
        sleep(3);
      end;
    end;
    lmarker.Latitude := lat;
  except
    on e: exception do
      showmessage(e.Message);
  end;
end;


  1. Please note that the behavior of the map you described is by design. The time it takes to load the map tiles depends on the speed of the internet connection and the tileserver which we have no control over.  I'm not sure if there is an alternative technique available for this specific scenario.