我正在开发 html5 Windows Phone 8 应用程序,但遇到了问题:地理定位对我不起作用。我将 WebBrowser.IsGeolocationEnabled
属性设置为 true,并且在应用程序 list ID_CAP_LOCATION
中也进行了检查。 Hovewer 即使从各种 HTML5 学习门户网站复制粘贴了地理定位代码,我仍然收到错误消息,提示该网站没有地理定位权限。
感谢您的帮助
var watchId = navigator.geolocation.watchPosition(scrollMap, handleError);
function scrollMap(position) {
myLoc.setLatLng([position.coords.latitude, position.coords.longitude]);
}
function handleError(error) {
myLoc.setLatLng([0, 0]);
}
最佳答案
我有同样的问题,但通过完全重写我的代码解决了它 - 简化它:
var lng, lat;
function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { alert("Geolocation is not supported by this browser."); } } function showPosition(position) { alert("Latitude: " + position.coords.latitude + "\nLongitude: " + position.coords.longitude); lng = position.coords.longitude; lat = position.coords.latitude; }
关于html - Windows Phone HTML 应用程序中的地理位置无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16295562/