Windows Phone HTML App中的地理位置无法正常工作

时间:2013-04-30 08:38:37

标签: html5 geolocation windows-phone-8

我正在开发html5 windows phone 8应用程序而且我遇到了问题:地理定位对我不起作用。我将WebBrowser.IsGeolocationEnabled属性设置为true,并且还检查了app manifest 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]);
    }

1 个答案:

答案 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;

        }