我试图计算我的路线,从我的当前位置到特定位置(var:end)。我想如何从我目前的位置获得我的LatLng? THX如何获得GMAPS API V3的当前经纬度位置?
这里是我的代码:
function calcRoute() {
var start = "How to get this LatLng ?";
var end = new google.maps.LatLng(-6.28529,106.871542);
var request = {
origin:start,
destination:end,
travelMode: google.maps.TravelMode.WALKING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
您需要使用手机上的gps。下面是如何设置它的链接:http://developer.android.com/guide/topics/location/strategies.html – Scott
我得到了我的设备位置,但我只需要Lat和Lng号码?怎么样 ? – user2565280