网络视图 windows phone 8.1

WebView windows phone 8.1

我在我的应用程序中显示 WebView,我显示的 WebView 需要 gps 位置,但由于某些原因 WebView 没有检索到位置。

有什么方法可以让 WebView 获得位置,或者有什么方法可以将位置传递给 WebView?

我已经通过在事件 NavigationCompleted:

中使用此代码向 WebView 注入一些 JS 来解决问题
var geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 500;
geolocator.MovementThreshold = 50;
geolocator.ReportInterval = 1000;

position = await geolocator.GetGeopositionAsync();

var js = $"var pos = new google.maps.LatLng({position.Coordinate.Point.Position.Latitude}, {position.Coordinate.Point.Position.Longitude});";

await webView.InvokeScriptAsync("eval", new List<string>() { js });