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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...