Jump to content

UniFSMap. Not right calculate distance and duration value from points in multi route


artem_niko

Recommended Posts

Good day!
Since the Falcoln Components component developer does not respond in any way to my questions, which I asked both through private messages and via email, I receive complete ignorance and do not receive answers to questions important to me (it is very disappointing that as soon as you buy components, then the developer no longer cares about you and your questions and the developer does not want to provide support, does it, @Marlon Nardi?)

Question: Why values of distance and duration calculate only from point A to point B, when I creating multi route?

image.thumb.png.12a9b58657bada8d0a200068388091c6.png

As result, I get not right value:

image.png.94b99a3b2f74a08a5e8198614fdf2cc9.png

But, I need get values of duration and distance from point A to point I.

Code:

procedure TUniFormPreviewMap.UniFSMap1AjaxEvent(Sender: TComponent;
  EventName: string; Params: TUniStrings);
var
  vJSON: string;
  Obj: TJsonObject;
  vI: Integer;
begin
  if EventName = 'fs_directions_changed' then
  begin
    vJSON := Params.Values['directionsDisplay'];

    Obj := TJsonBaseObject.Parse(vJSON) as TJsonObject;
    try
      lblDistance.Text := Obj.S['distancetext'];
      lblDuration.Text := Obj.S['durationtext'];

      ClientDataSet1.CreateDataSet;
      ClientDataSet1.DisableControls;
      try
        ClientDataSet1.EmptyDataSet;

        for vI := 0 to Obj.A['steps'].Count - 1 do
        begin
          ClientDataSet1.Append;
          ClientDataSet1.FieldByName('sequence').AsInteger := vI + 1;

          ClientDataSet1.FieldByName('enc_lat_lngs').AsString := Obj.A['steps'].Values[vI].S['enc_lat_lngs'];

          ClientDataSet1.FieldByName('instructions').AsString := Obj.A['steps'].Values[vI].S['instructions'];
          ClientDataSet1.FieldByName('distance_value').AsInteger := Obj.A['steps'].Values[vI].I['distancevalue'];
          ClientDataSet1.FieldByName('distance_text').AsString := Obj.A['steps'].Values[vI].S['distancetext'];
          ClientDataSet1.FieldByName('duration_value').AsInteger := Obj.A['steps'].Values[vI].I['durationvalue'];
          ClientDataSet1.FieldByName('duration_text').AsString := Obj.A['steps'].Values[vI].S['durationtext'];

          ClientDataSet1.FieldByName('startlocation_lat').AsString := Obj.A['steps'].Values[vI].O['startlocation'].S['lat'];
          ClientDataSet1.FieldByName('startlocation_lng').AsString := Obj.A['steps'].Values[vI].O['startlocation'].S['lng'];
          ClientDataSet1.FieldByName('endlocation_lat').AsString := Obj.A['steps'].Values[vI].O['endlocation'].S['lat'];
          ClientDataSet1.FieldByName('endlocation_lng').AsString := Obj.A['steps'].Values[vI].O['endlocation'].S['lng'];

          ClientDataSet1.Post;
        end;
      finally
        ClientDataSet1.First;
        ClientDataSet1.EnableControls;
      end;
    finally
      Obj.Free;
    end;
  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...