Thema: Delphi Geolocation Windows API

Einzelnen Beitrag anzeigen

Benutzerbild von dtpfl
dtpfl

Registriert seit: 19. Jan 2018
Ort: Bayern
20 Beiträge
 
Delphi 12 Athens
 
#1

Geolocation Windows API

  Alt 18. Aug 2022, 17:45
Hallo Leute,

ich werde verrückt, ich versuche über die Windows API den Standort zu bekommen, da TLocationSensor nicht (mehr) funktioniert. https://quality.embarcadero.com/browse/RSP-38580
Dafür will ich https://docs.microsoft.com/de-DE/uwp...ew=winrt-22621 benutzen, es gibt dies sogar schon in Delphi Winapi.Devices.Geolocation.

Ich habe ein C# Beispielprojekt kompiliert hier funktioniert es einwandfrei (https://github.com/microsoft/Windows...sition.xaml.cs)
Code:
var accessStatus = await Geolocator.RequestAccessAsync();

            switch (accessStatus)
            {
                case GeolocationAccessStatus.Allowed:

                    _geolocator = new Geolocator { ReportInterval = 2000 };
                    _geolocator.PositionChanged += OnPositionChanged;
                    _geolocator.StatusChanged += OnStatusChanged;
                    break;
Nun bekomme ich einen Fehler dass die Schnittstelle nicht unterstützt wird, jetzt bin ich komplett gebrochen...
Hier ist ein Ausschnitt meines Codes (der Rest ist im Anhang)t:
Code:
procedure statusCompletedAccess(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus);

TAccessStatusCompletedHandlerCompleted = procedure(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus) of object;

type TAccessStatusCompletedHandler = class(TInspectableObject, AsyncOperationCompletedHandler_1__GeolocationAccessStatus)
  private
    FEvent: TAccessStatusCompletedHandlerCompleted;
  public
    procedure Invoke(asyncInfo: IAsyncOperation_1__GeolocationAccessStatus; asyncStatus: AsyncStatus); safecall;
    constructor Create(AEvent: TAccessStatusCompletedHandlerCompleted);
  end;

constructor TAccessStatusCompletedHandler.Create(
  AEvent: TAccessStatusCompletedHandlerCompleted);
begin
  FEvent := AEvent;
end;

procedure TAccessStatusCompletedHandler.Invoke(
  asyncInfo: IAsyncOperation_1__GeolocationAccessStatus;
  asyncStatus: AsyncStatus);
begin
  FEvent(asyncInfo, asyncStatus);
end;

procedure TForm9.statusCompletedAccess(
  asyncInfo: IAsyncOperation_1__GeolocationAccessStatus;
  asyncStatus: AsyncStatus);
begin
  ShowMessage('JAA!!!');
end;
Gibt es hierfür eine Lösung oder eine gute alternative zu TLocationSensor um durchgehend den Standort ermitteln zu können? Dies muss unter Windows und auch Offline (GPS) funktionieren!

Falls dies aufwendiger ist und jemand das Interesse hat mir dabei zu helfen, könnte ich evtl. meinen Arbeitgeber fragen ob dieser dann auch "entschädigt" wird
Testprojekt im Anhang.
Angehängte Dateien
Dateityp: zip LocationCheck.zip (8,1 KB, 8x aufgerufen)
  Mit Zitat antworten Zitat