简体   繁体   English

Google Direction API无法正常运作

[英]Google direction api not working correctly

I am working on a java program where I use text search and directions api, but somehow api's are not working correctly in some cases. 我正在使用文本搜索和路线api的Java程序上工作,但是在某些情况下api无法正常工作。

For example: I have to search "restaurants" near Hyundai Car Center,Sector 63, Noida . 例如:我必须在Hyundai Car Center,Sector 63, Noida附近搜索“ restaurants”。

For this I have used the text search api to get the formatted address of the required restaurant. 为此,我使用了文本搜索API来获取所需餐厅的格式化地址。 Now when I used direction api to calculate the shortest time and distance between the locations, I did not find any result. 现在,当我使用direction api计算位置之间的最短时间和距离时,我没有找到任何结果。

String addressFrom = "Mother Dairy, Bhim Nagri, Hauz Khas, New Delhi, India";
String addressTo = "Hyundai Car Center,Sector 63,Noida";
String urlString = "http://maps.googleapis.com/maps/api/directions/xml?sensor=true&origin="
                + addressFrom + "&destination=" + addressTo;
System.out.println(urlString);

I am getting the following output: 我得到以下输出:

http://maps.googleapis.com/maps/api/directions/xml?sensor=true&origin=Mother+Dairy%2C+Bhim+Nagri%2C+Hauz+Khas%2C+New+Delhi%2C+India&destination=Hyundai+Car+Center%2CSector+63%2CNoida
<?xml version="1.0" encoding="UTF-8"?>
<DirectionsResponse>
 <status>NOT_FOUND</status>
</DirectionsResponse>

The problem is that "Mother Dairy, Bhim Nagri, Hauz Khas, New Delhi, India" cannot be found. 问题是找不到“印度新德里豪兹·哈斯的比姆·纳格里母亲奶业”。 You can test whether the endpoints can be found by entering them (one at a time) in the Google Geocoder Sample page . 您可以通过在Google Geocoder示例页面中一次输入一个端点来测试是否可以找到这些端点。

However, "Bhim Nagri, Hauz Khas, New Delhi, India" can be found, and is fairly close to where "Mother Dairy" is marked on the map. 但是, 可以找到“印度新德里Hauz Khas的Bhim Nagri”,并且非常接近地图上标有“母亲乳业”的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM