C# WebView windows phone 8.1

C# WebView windows phone 8.1,c#,xaml,webview,windows-runtime,winrt-xaml,C#,Xaml,Webview,Windows Runtime,Winrt Xaml,我在我的应用程序中显示一个WebView,我显示的WebView需要gps位置,但由于某种原因,WebView无法检索位置 有一种方法可以让WebView获得位置,或者通过某种方式将位置传递给WebView?我通过在事件导航完成中使用此代码向WebView注入一些JS来解决这个问题: var geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 500; geolocator.MovementThreshold =

我在我的应用程序中显示一个
WebView
,我显示的
WebView
需要gps位置,但由于某种原因,
WebView
无法检索位置


有一种方法可以让
WebView
获得位置,或者通过某种方式将位置传递给
WebView

我通过在事件
导航完成
中使用此代码向
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 });
var geologitor=new geologitor();
geolocator.DesiredAccuracyInMeters=500;
geolocator.MovementThreshold=50;
geolocator.ReportInterval=1000;
位置=等待地理定位器。GetGeopositionAsync();
var js=$“var pos=new google.maps.LatLng({position.Coordinate.Point.position.Latitude},{position.Coordinate.Point.position.Longitude});”;
等待webView.InvokeScriptAsync(“eval”,new List(){js});

我已经解决了这个问题,在事件
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 });
var geologitor=new geologitor();
geolocator.DesiredAccuracyInMeters=500;
geolocator.MovementThreshold=50;
geolocator.ReportInterval=1000;
位置=等待地理定位器。GetGeopositionAsync();
var js=$“var pos=new google.maps.LatLng({position.Coordinate.Point.position.Latitude},{position.Coordinate.Point.position.Longitude});”;
等待webView.InvokeScriptAsync(“eval”,new List(){js});

带“用户位置”的是指gps位置吗?是的,我指的是gps位置。在web视图中,是否从url地址呈现真实网页?例如你需要从网页上获取gps位置吗?是的,我正在渲染一个真实的网页,我需要网页来获取手机gps位置。我正在考虑通过调用InvokeScriptasync来注入gps位置。这里最好的技术是使用C#获取gps位置,并使用InvokeScriptasync和“用户位置”来注入gps位置。你是指gps位置吗?是的,我是指gps位置。在web视图中,是否从url地址呈现真实网页?例如你需要从网页上获取gps位置吗?是的,我正在渲染一个真实的网页,我需要网页来获取手机gps位置。我正在考虑通过调用InvokeScriptAsync来注入gps位置。这里最好的技术是使用C#获取gps位置,并使用InvokeScriptAsync注入gps位置