We have a web app that shows an ESRI map with a locate me button, the button is working on the web browser, but it's not working on the Android web view, also the location permission is enabled, see code below:
the error we get on the CONSOLE: INFO:CONSOLE(285)] "Error: User denied Geolocation
the location permission enabled:
requestPermissions(
activity,
arrayOf(android.Manifest.permission.ACCESS_FINE_LOCATION,ACCESS_COARSE_LOCATION),
1)
@SuppressLint("SetJavaScriptEnabled")
@Composable
fun LoadWebView(url: String) {
MyTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
Column {
val state = rememberWebViewState(
url
)
val loadingState = state.loadingState
if (loadingState is LoadingState.Loading) {
LinearProgressIndicator(
progress = loadingState.progress,
modifier = Modifier.fillMaxWidth()
)
}
WebView(
state, onCreated = {
it.settings.javaScriptEnabled = true
it.settings.allowContentAccess = true
it.settings.allowFileAccess = true
it.settings.loadWithOverviewMode = true
it.settings.useWideViewPort = true
it.settings.domStorageEnabled = true
it.settings.javaScriptCanOpenWindowsAutomatically=true
it.settings.databaseEnabled = true
it.settings.setSupportMultipleWindows(true)
it.settings.setGeolocationEnabled(true)
it.webChromeClient = object : WebChromeClient() {
override fun onGeolocationPermissionsShowPrompt(
origin: String,
callback: GeolocationPermissions.Callback
) {
callback.invoke(origin, true, false)
}
}
}, modifier = Modifier.fillMaxSize()
)
}
}
}
}
Solved! Go to Solution.
Thank you everyone for your support.
The issue was solved after switching from jetpack compose to normal layout.
Thanks for bringing your question to Esri Community, @ElieRizk.
Because this area is used for members to provide our team with feedback about our online community, I'd like to help get your post moved over to one of our conversation boards where it's more likely to be seen and responded to by members who can help. Which ArcGIS product are you using?
@JesseCloutier Thank you.
We are using Javascript API locate widget.
@ElieRizk I've moved this conversation to the ArcGIS JavaScript Maps SDK Questions Board. All the best!
@JesseCloutier Since we moved the post to this section we haven't received any feedback.
kindly any support is highly appreciated to solve the issue.
Thank You,
From the error message, seems like the app do not have permission to access the devices location. Might want to check the app security or setting again if location enabled.
@RamaniGanason Location is already enabled as we mentioned in our post.
we checked it again and the problem persists.
Hi @ElieRizk , I would love to replicate this so that I'm able to help further. Can let know the tech stack that you are currently using and the android version that you are testing against.
@RamaniGanason hello, thank you for your support.
We use Kotlin Jetpack Compose as a development language, Android version 15 with the following workflow:
We have a web app javascript that shows an ESRI map with a locate ESRIJs widget, the locate widget is working fine on the web browsers, but it's not working on the Android web view yet it is working on the IOS web view, in addition on android all the needed permissions are enabled.
In case it helps with troubleshooting, the SDK's locate widget uses the native Geolocation API under the hood. So, if you can build a simple app for testing with just the Geolocation API, that functionality would be similar to the widget's.