【问题标题】:Geolocation in Windows Phone HTML App not workingWindows Phone HTML 应用程序中的地理位置不起作用
【发布时间】:2013-04-30 08:38:37
【问题描述】:

我正在开发 html5 windows phone 8 应用程序,但遇到了问题:地理定位对我不起作用。我将WebBrowser.IsGeolocationEnabled 属性设置为true,并且在应用程序清单中ID_CAP_LOCATION 也被选中。但是,即使从各种 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]);
    }

【问题讨论】:

  • 您是否也将WebBrowser 中的IsScriptEnabled 设置为true
  • 是的,我已经检查过 - js 工作,地理位置 - 不 :(
  • 我遇到了同样的问题。我知道 javascript 正在工作,因为错误消息是使用 alert(); 显示的

标签: html geolocation windows-phone-8


【解决方案1】:

我有同样的问题,但通过完全重写我的代码来解决它 - 简化它:

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;

        }

【讨论】:

    猜你喜欢
    • 2016-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    • 1970-01-01
    相关资源
    最近更新 更多