AntonioCuomo Posted December 1, 2020 Posted December 1, 2020 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 Quote
Sherzod Posted December 1, 2020 Posted December 1, 2020 Hello, Make a simple testcase if possible, to understand your code. Quote
AntonioCuomo Posted December 1, 2020 Author Posted December 1, 2020 Here is the project. for access matricola = 20017 and password = 12345678 Thank WebPresenze.zip Quote
AntonioCuomo Posted December 1, 2020 Author Posted December 1, 2020 This is test rin ok testgeolaction.zip Quote
AntonioCuomo Posted December 9, 2020 Author Posted December 9, 2020 after many tests I have verified that: the demo on localhost: 8100 geolocation works if I open the application from upc on the net (192.168.1.9:8100) the geolocation does not work Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.