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;
// 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 !!