Hi community,
I am loading a web mapping application, from my Arcgis enterprise shared for public with full privileges, in my MAUI application.
The location widget, located in the web mapping app. returns "Location dinied". But when I open it in any web explorer, it works perfectly.
here is my code in MainPage.xaml:
<WebView x:Name="MyWebView"
Source="https://xyzxyzxyzx/portal/apps/webappviewer/index.html?id=124f8e1fcd8141319cd51655b64d446e"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" />
In AndroidManifest.xml :
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
</manifest>
Please, Help
Hi,
You also need to explicitly include logic in your app to request this permission at run-time.
var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
// Request location permission if not granted.
if (status != PermissionStatus.Granted)
{
status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>();
}
thanks for your answer.
Please, how con I do that ?
there is what i have in codes
private async void CheckAndRequestLocationPermission() { var status = await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>(); if (status != PermissionStatus.Granted) { status = await Permissions.RequestAsync<Permissions.LocationWhenInUse>(); } if (status == PermissionStatus.Granted) { GetLocation(); } else { await DisplayAlert("Permission Denied", "Unable to access location.", "OK");
Since you aren't using the Maps SDK for .NET MAUI but using the JavaScript SDK, it's not quite the right forum. However a quick google search reveals a few settings and things you need to do to enable location in embedded webviews: https://stackoverflow.com/questions/5329662/android-webview-geolocation