我有一个Web应用程序,它显示不同位置的纬度和经度数据。我正在尝试使用通过Xamarin中的Web视图开发的android应用程序打开同一Web应用程序。但是纬度和经度显示为空白。当我使用Chrome浏览器时,效果很好。请帮我。
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.layout3);
web_view = FindViewById<WebView>(Resource.Id.webview);
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.SetGeolocationEnabled(true);
web_view.SetWebViewClient(new HelloWebViewClient());
web_view.SetWebChromeClient(new GeoWebChromeClient());
web_view.Settings.JavaScriptCanOpenWindowsAutomatically = true;
web_view.Settings.DisplayZoomControls = true;
web_view.Settings.JavaScriptEnabled = true;
web_view.Settings.SetGeolocationEnabled(true);
web_view.LoadUrl("https://abcd.com");
}
class GeoWebChromeClient : WebChromeClient
{
public override void OnGeolocationPermissionsShowPrompt(string origin, GeolocationPermissions.ICallback callback)
{
callback.Invoke(origin, false, false);
}
}
class HelloWebViewClient:WebViewClient
{
// For API level 24 and later
public override bool ShouldOverrideUrlLoading(WebView view, IWebResourceRequest request)
{
view.LoadUrl(request.Url.ToString());
return false;
}
}
答案 0 :(得分:1)
将其添加到清单文件中。
db.collection.aggregate(
[
{$match:{storeId:{$in:[
ObjectId("e069d1b76557685b9e235v"),ObjectId("e069d1b76557685b9t7j8n"),
ObjectId("e069d1b76557685b9e2fg6"),ObjectId("e069d1b76557685b9p56r2")
]},
timeStamp: {$gt: ISODate(createdAt)},
}},
{$group:{_id:"$storeId", week: { $week: '$timeStamp'}, totalPoints: {$sum: "$points"}, averagePoints: {$avg: "$points"}} },
{$sort: {totalPoints:-1}}
])
在“活动”中添加此内容:之后,尝试获取位置值。
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />