Jump to content

geolocation with app desktop unigui


AntonioCuomo

Recommended Posts

in a unigui windows application I want to insert the geolocation of the pc with the following source.

procedure TMainForm.UniBitBtn1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
UniMemo1.Lines.Add(eventname);

if EventName = 'CurrentPosition' then
   begin
    UniMainModule.latidu := Params['lat'].Value;
    UniMainModule.longi  := Params['lng'].Value;

    if accedi(StrToInt(UniNumberEdit1.text), uniedit3.Text, UniEdit2.text) = 0 then
                                                               UniForm1.ShowModal();
   end;
end;

procedure TMainForm.UniBitBtn1Click(Sender: TObject);
begin
unisession.AddJS(
 'if (navigator.geolocation) { ' +
    '  navigator.geolocation.getCurrentPosition( function(position) { ' +
    '    ajaxRequest(MainForm.uniBitBtn, "CurrentPosition" ,' +
    '      ["lat=" + position.coords.latitude, ' +
    '       "lng=" + position.coords.longitude, ' +
    '      ]);' +
    '    })' +
    '} else {alert("Geolocation is not supported.");}'
);

//if accedi(StrToInt(UniNumberEdit1.text), uniedit3.Text, UniEdit2.text) = 0 then
//                                                           UniForm1.ShowModal();
end;

In the test procedure it works and detects the CurrentPosition event, when I transfer the source in my application unibitbtn ajaxevent detects only the click event and not CurrentPosition

Link to comment
Share on other sites

  • 2 weeks later...

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...