WinRT GetGeopositionAsync works in JavaScript not in C++?
-
12-11-2019 - |
Вопрос
Just curious if this is a bug or if I'm doing it wrong. I'm trying to use the Geolocator from WinRT. I have a test Metro app in Javascript and everything works with this code:
var locator = Windows.Devices.Geolocation.Geolocator();
var promise = locator.getGeopositionAsync().then(
function (pos) {
Loc.innerText = "Lat: " + pos.coordinate.latitude + ", Lng: " + pos.coordinate.longitude;
});
I'm trying to do the same thing in C++ app with this code but it doesn't ever enter my lambda:
auto locator = ref new Geolocator();
auto operation = locator->GetGeopositionAsync();
operation->Completed = ref new AsyncOperationCompletedHandler< Geoposition^ >(
[=](IAsyncOperation<Geoposition^>^ operation)
{
auto result = operation->GetResults();
std::wstringstream ss;
ss << L"Lat: " << result->Coordinate->Latitude << L", Lng: " << result->Coordinate->Longitude;
this->Loc->Text = ref new String( ss.str().c_str() );
});
I've turned on the Location capability in both apps. Any suggestions?
Нет правильного решения
Не связан с StackOverflow