【问题标题】:My website "Current location" function does now work on android devices我的网站“当前位置”功能现在可以在安卓设备上使用
【发布时间】:2013-11-25 15:02:29
【问题描述】:

这是我在点击链接时调用的函数,它在 iPhone 和 PC/Apple 设备浏览器上运行良好,但在任何 Android 设备浏览器中都不起作用:

  function currentLocation() {

      // Initialize the Google Maps API v3

      var MyMarker = null;

      function autoUpdate() {

      if (navigator.geolocation) {    
        navigator.geolocation.getCurrentPosition(function(position) {
          var newPoint = new google.maps.LatLng(position.coords.latitude, 
                                                position.coords.longitude);

          if (MyMarker) {
            // Marker already created - Move it
            MyMarker.setPosition(newPoint);
          }
          else {
            // Marker does not exist - Create it
            marker = new google.maps.Marker({
              position: newPoint,
              map: map
            });
          }

          // Center the map on the new position
          map.setCenter(newPoint);
        });

        } // End if

        // Call the autoUpdate() function every 5 seconds
        setTimeout(autoUpdate, 5000);
      }

      autoUpdate();

  }

一旦我访问包含此脚本的页面并按下按钮以显示我当前的位置设备确实要求我让我共享位置,但没有任何反应。控制台没有错误。

请就如何使其适用于基于 android 的设备提供建议。

【问题讨论】:

  • html5demos.com/geo - 这个链接在我的安卓手机上也不起作用!有什么想法???

标签: javascript google-maps-api-3 cross-platform android-browser


【解决方案1】:

您是否在多部手机上进行过测试?

您可能需要启用定位服务:https://support.google.com/coordinate/answer/2569281?hl=en

【讨论】:

  • 是的,我的位置服务已启用。我在 Acer s500 和三星 Galaxy 平板电脑上测试过
  • html5demos.com/geo - 这个链接在我的安卓手机上也不起作用!任何想法为什么???
猜你喜欢
  • 1970-01-01
  • 2017-01-19
  • 2014-07-07
  • 1970-01-01
  • 2013-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多