【问题标题】:ie9 not supporting geolocation?ie9不支持地理位置?
【发布时间】:2012-05-29 20:06:19
【问题描述】:

大家好, 我正在创建一个使用 Geolocation API 来定位最终用户的 Web 应用程序。它在我能想到的几乎所有平台上都运行良好,除了 Internet Explorer 9。不过事情变得有点奇怪。如果我将 Google 工具栏加载到我的 Internet Explorer 浏览器窗口中,一切都会顺利进行。这是我一直在使用的有问题的代码块:

if (navigator.geolocation) {
            var locationMarker = null;
            navigator.geolocation.watchPosition(
                function( position ){
                    var point = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);    
                    if (!locationMarker) {
                        locationMarker = addMarker(
                            position.coords.latitude,
                            position.coords.longitude,
                            "Initial Position"
                        );
                    }
                    else{
                        updateMarker(
                            locationMarker,
                            position.coords.latitude,
                            position.coords.longitude,
                            "Updated / Accurate Position"
                        );
                    };
                    map.setCenter(point);
                    if (map.zoom < 17){
                        map.setZoom(17);
                    };
                },
                function( error ){
                    console.log( "Something went wrong: ", error );
                },
                {
                    timeout: (5 * 1000),
                    maximumAge: (1000 * 60 * 15),
                    enableHighAccuracy: true
                }
            );
        }
        else {
            alert("Geolocation is not supported by this browser");
        }

每当我使用 Internet Explorer 9 访问我的应用程序时,我都会收到“此浏览器不支持地理位置”警报。除非我激活了我的 Google 工具栏。但是,如果 Google 工具栏处于活动状态,则 Google 工具栏会处理权限。

如何让地理定位在 IE9 中工作?我的应用程序可以在 Safari、Firefox、Chrome、iOS 和 Android 中完美运行。我完全被难住了。

谢谢,泰勒·沃林

【问题讨论】:

    标签: geolocation internet-explorer-9


    【解决方案1】:

    用户1303379,

    IE9 和 IE10 都支持地理定位,但是早期版本的 IE 不支持它(参考 http://caniuse.com/#feat=geolocation )。这是 IE 的一篇博客文章,内容是关于 IE9 http://blogs.msdn.com/b/ie/archive/2011/02/17/w3c-geolocation-api-in-ie9.aspx 中的地理定位,这是一个使用 navigator.geolocation.watchPosition 的测试页面,就像您在上面一样。

    对于不支持地理定位的浏览器,您可以考虑使用此处列出的地理定位 polyfill 之一https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills

    IE9 和 IE10 询问用户是否愿意分享他们的位置 http://cl.ly/image/0X0o2F0s1N03 我的猜测是您可能在某个时候拒绝访问您的位置。

    Google 工具栏在 IE8 天添加了一项确定地理位置的功能http://googletoolbarhelp.blogspot.com/2010/02/google-toolbar-6413211732-for-ie.html 根据您的描述,听起来 Google 工具栏开始提供地理位置,因为原生 IE9 地理位置被拒绝访问。

    【讨论】:

      猜你喜欢
      • 2016-09-21
      • 2013-03-31
      • 2012-10-29
      • 1970-01-01
      • 2011-10-15
      • 2011-04-16
      • 1970-01-01
      • 2011-12-09
      • 2012-02-23
      相关资源
      最近更新 更多