frenk91
frenk91

Reputation: 929

WebView windows phone 8.1

I'm displaying a WebViewin my app, the WebView that I'm showing require the gps position, but for some reason the WebView does't retrieve the position.

There is a way to allow the WebView to get the position, or some way to pass the position to the WebView?

Upvotes: 1

Views: 86

Answers (1)

frenk91
frenk91

Reputation: 929

I have solved the issue by injecting some JS to the WebView by using this code inside the event NavigationCompleted:

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 });

Upvotes: 0

Related Questions