相关疑难解决方法(0)

android webview地理定位

我必须在a中检索用户的位置WebView.我使用以下Javascript执行此操作:

function getLocation() {
   navigator.geolocation.getCurrentPosition(displayLocation, handleError);
}
Run Code Online (Sandbox Code Playgroud)

但是权限请求弹出窗口永远不会打开.

我设置了这些设置:

ws.setJavaScriptEnabled(true);
ws.setGeolocationEnabled(true);
ws.setJavaScriptCanOpenWindowsAutomatically(true);
Run Code Online (Sandbox Code Playgroud)

从一个位置访问用户位置的正确方法是WebView什么?

android geolocation

97
推荐指数
6
解决办法
7万
查看次数

Xamarin Essentials地理位置无法正常运行,GetLocationAsync不再尝试

因此,我想获取用户位置并对其进行反向地理编码,以获取地址和街道号码。

因此,我安装了预发行版的Xamarin.Essentials软件包。我想使用地理定位和地理编码API,所以我写了一些代码,但是if (location != null)在尝试使用GetCurrentLocation时,这些代码永远无法到达。

我认为Xamarin.Essentials是否基于Xam.Plugin.Geolocator作者James Montemagno所说的预发行版并不重要:

我将继续工作和维护我的插件,但我建议您结帐Xamarin.Essentials,以查看它是否适合您的应用程序,因为它适用于我的所有应用程序!

资料来源:https : //github.com/jamesmontemagno/GeolocatorPlugin

我做了什么?

我已搜索有关我遇到的问题的StackOverflow问题,但据我所知,找不到我能帮助我的问题。

我看过的问题:

我还尝试了添加超时是否可行: var request = new GeolocationRequest(GeolocationAccuracy.Medium, timeout: TimeSpan.MaxValue );

但是我在位置上也遇到了同样的问题。它从未到达if语句。

我的代码:

FillInLocationInForm(); 是在我的Page构造函数中设置的。

public Location location;并且public Placemark placemark;在Page类中设置。

这些是Page类中的相关功能:

public async void FillInLocationInForm()
    {
        if (await GetCurrentLocation())
        {
            if (await ReverseGeocodeLocation())
            {
                await this.DisplayAlert("Location", placemark.AdminArea + " " + placemark.FeatureName + " " + placemark.Locality + " " + …
Run Code Online (Sandbox Code Playgroud)

c# android xamarin xamarin.forms xamarin.essentials

5
推荐指数
1
解决办法
3478
查看次数