andersonrsbezerra Posted February 7, 2018 Share Posted February 7, 2018 Como capturar latitude e longitude atual no unigui mobile? Quote Link to comment Share on other sites More sharing options...
asapltda Posted November 21, 2023 Share Posted November 21, 2023 +1 Quote Link to comment Share on other sites More sharing options...
DFong Posted November 22, 2023 Share Posted November 22, 2023 I've used the following on mobile in response to a Button click on a simple dialog form named InputBox which has a TunimEdit control named InputEdit. You should be able to figure it out from the code snippets below: procedure TInputBox.GeoButtonClick(Sender: TObject); var GetLatLong : string; begin UniSession.AddJS('InputBox.OKButton.showMask("Locating...");'); GetLatLong := 'if (navigator.geolocation) {'+ ' navigator.geolocation.getCurrentPosition(showPosition); '+ ' } else { '+ ' alert("Geolocation is not supported by this browser."); '+ ' InputBox.OKButton.hideMask(); '+ ' } '+ ' function showPosition(position) { '; if (pos(' LATITUDE ',Uppercase(Caption))>0) then GetLatLong := GetLatLong + ' ajaxRequest(InputBox.InputEdit,"Latitude",["Latitude="+position.coords.latitude+""]); }' else GetLatLong := GetLatLong + ' ajaxRequest(InputBox.InputEdit,"Longitude",["Longitude="+position.coords.longitude+""]); }'; UniSession.AddJS(GetLatLong); end; procedure TInputBox.InputEditAjaxEvent(Sender: TComponent; EventName: string; Params: TUniStrings); var Key : word; Latitude,Longitude : string; begin if (EventName='keypress') then begin Key := StrToInt(Params.Values['key']); if ord(Key)=13 then //Enter-key pressed begin FCallBack(trim(InputEdit.Text)); Close; end; end else if EventName='Latitude' then begin Latitude := Params.Values['Latitude']; //ShowMessage('Latitude: '+Latitude); InputEdit.Text := Latitude; UniSession.AddJS('InputBox.OKButton.hideMask();'); end else if EventName='Longitude' then begin Longitude := Params.Values['Longitude']; //ShowMessage('Latitude: '+Latitude); InputEdit.Text := Longitude; UniSession.AddJS('InputBox.OKButton.hideMask();'); end end; Quote Link to comment Share on other sites More sharing options...
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.