我在执行反向地理编码时做错了什么

时间:2011-07-27 07:56:37

标签: google-maps google-maps-api-3

我正在尝试反向地理编码,我有三个坐标,我想将它们转换为地址,我使用了以下方法。

var point1 = new google.maps.LatLng(latLng1);

var point2 = new google.maps.LatLng(latLng2);

var point3 = new google.maps.LatLng(latLng3);

where latLng1, latLng2, latLng3 are coordinates.

and then further I want to use these addresses to following code to create a path

var request = {

        origin:location1, 

        destination:location2,

        waypoints:[{location: point1}, {location: point2}, {location: point3}],

        travelMode: google.maps.DirectionsTravelMode.WALKING

        };

但它从不显示任何内容。

我做得对吗,在谷歌APIv3中还有一件事我们可以在路标或latlng中使用地址字符串。我们如何在航点上使用latlag。

1 个答案:

答案 0 :(得分:0)

你在这里展示你的整个代码吗? 请发布您的latLng1值,例如。 另外,请显示您的路线服务电话。我喜欢这样:

    directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            directionsDisplay.setDirections(response);
        } else alert(status);
    });

在任何情况下 - 尝试提醒()您的请求状态,这些点可能无法提供指示。

顺便说一下,您不需要将坐标地理编码为地址以获取路线。您可以在航点中使用坐标,这就是您在这里所做的。

相关问题