[英]WebView windows phone 8.1
I'm displaying a WebView
in my app, the WebView
that I'm showing require the gps position, but for some reason the WebView
does't retrieve the position. 我显示WebView
在我的应用程序,该WebView
是我展示所需要的GPS位置,但由于某些原因WebView
简化版,检索其位置。
There is a way to allow the WebView
to get the position, or some way to pass the position to the WebView
? 有一种方法可以让WebView
获取位置,或者某种方式将位置传递给WebView
?
I have solved the issue by injecting some JS to the WebView
by using this code inside the event NavigationCompleted
: 我已经通过在事件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 });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.