我正在尝试将latitued和经度打印到控制台,但是我的代码没有显示任何内容。它似乎适用于JSfiddle,但不适用于我的桌面。
public static async Task<byte[]> GetPostContentAsync(string url, string data)
{
var content = new MemoryStream();
var cookies = new CookieContainer();
HttpWebRequest webReq;
webReq = (HttpWebRequest)WebRequest.Create(url);
webReq.CookieContainer = cookies;
webReq.Method = "POST";
webReq.ContentType = "application/x-www-form-urlencoded";
Stream requestStream = await webReq.GetRequestStreamAsync();
using (var writer = new StreamWriter(requestStream))
{
await writer.WriteAsync(data);
}
using (var responseStream = await webReq.GetResponseAsync())
{
using (Stream response = responseStream.GetResponseStream())
{
await response.CopyToAsync(content);
}
}
return content.ToArray();
}
答案 0 :(得分:0)
如果授予,拒绝或提示,您可以找到新的权限api(仅适用于firefox和blink)
您还可以使用错误回调来确定是否有任何问题获得位置
navigator.permission.query({name: 'geolocation'}).then(permission => {
alert(permission.state)
})
navigator.geolocation.getCurrentPosition(success, error);
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message)
}