gmap3 API - geoLatlng没有给出确切的位置

时间:2012-08-21 10:51:44

标签: javascript google-maps geolocation jquery-gmap3

我正在使用gmap3的地理定位服务来获取用户的位置,并将其指示给预定目的地。

目的地是(后面评论的坐标):

var dest = "Unit 20, Tallaght Business Centre, Whitestown Road, Tallaght Business Park, Ireland";//53.282882, -6.383155

使用以下内容寻找用户的位置(我正在办公室进行所有开发,这与dest完全相同):

//get user's location
        function getLocation(){
            $('#map').gmap3(
            { action : 'geoLatLng',
              callback : function(latLng){
                if (latLng){
                  plotRoute(latLng, dest);
                  alert(latLng); //this alerts (53.34410399999999, -6.267493000000059), should be my exact location which is the same as 'dest'
                  return;
                } else {
                  alert("Unable to determine your location. Enable geolocation services and try again, or consult the map for our location.");
                  $('#directions-panel').text("We were unable to give you directions. Please enable geolocation services on your device to see directions from your location to our office.");
                  plotMarker(dest);
                }
              }
            });
          }

所以理论上alert(Latlng);提醒的内容应与dest完全相同,不是吗?

这纯粹是因为gmap3在精确定位用户位置方面的局限性,还是我做错了什么?我会更好地使用Google Maps JavaScript API v3吗?

完整的脚本可以在这里看到: http://pastebin.com/Vz1syjvE

所有人都很感激。

0 个答案:

没有答案