WebMap launchs two times

Hi, I have the next code on the afterdownloadmap event.

    WebGMapsGeocoding.Address := edt_From.Text;

    // add marker
    if WebGMapsGeocoding.LaunchGeocoding = erok then
        WebMap.Markers.Add( WebGMapsGeocoding.ResultLatitude,   WebGMapsGeocoding.ResultLongitude, edt_From.Text );

    WebMap.MapOptions.DefaultLatitude  := WebGMapsGeocoding.ResultLatitude;
    WebMap.MapOptions.DefaultLongitude := WebGMapsGeocoding.ResultLongitude;

    nLatitude  := WebGMapsGeocoding.ResultLatitude;
    nLongitude := WebGMapsGeocoding.ResultLongitude;

    WebGMapsGeocoding.Address := edt_To.Text;

    // add marker
    if WebGMapsGeocoding.LaunchGeocoding = erok then
        WebMap.Markers.Add( WebGMapsGeocoding.ResultLatitude, WebGMapsGeocoding.ResultLongitude, edt_To.Text );

    WebMap.GetDirections( edt_From.Text, edt_To.Text , True, tmDriving, usMetric, lnSpanish, True, True, nil, False );

    if WebMap.Directions.Count > 0 then
    begin

        edt_Distance.Text := IntToStr( WebMap.Directions[0].TotalDistance ) + ' mts.';

        WebMap.DeleteAllMapPolyline;
        WebMap.DeleteAllMapPolygon;

        MapDirectionList.Clear;

        WebMap.FillRouteList(ListBox1.Items, usMetric);
        WebMap.FillDirectionList( MapDirectionList.Items );

        WebMap.CreateMapPolyline( WebMap.Directions[0].Polyline );

        WebMap.MapPanTo( nLatitude , nLongitude );

    end;

Apparently, the webmap launchs two times, one becase of the autolaunch property, and then executes the previous code.
It is possible when opening the form that contains the map, to directly shows my two markers ? In some slow computers , it is clear that first launch a map with the default coordinates and then launchs again because of the code.

Its anything wrong with the code?? Could be faster ?

Hope my question is clear enough to anyone ..

Many thanks !!

Hi,


Please note if you call the MapPanTo from the OnDownloadFinish event the map will first be loaded while it's positioned at the DefaultLatitude / DefaultLongitude. Then the position will change to the new coordinates.

If you want to the map to load after setting the new coordinates follow these steps:
Set AutoLaunch to false.
Retrieve and set the new DefaultLatitude / DefaultLongitude coordinates from the Form's OnShow event.
Display the map with the "Launch" call.
Add the required markers from the OnDownloadFinish event.
Thank you so much Bart.

It works perfect now.