1

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

すべての助けに感謝します。

4

0 に答える 0