在我的应用程序中,我正在尝试获取我当前位置附近的美容院的位置。为此,我使用了google places API。正如链接中所提到的,我正在尝试获取有关美容院的所有信息。为此,我使用了以下代码
private void onPerformSearch() {
double lat=gePoint_pt.getLatitudeE6()/1E6;
double lon=gePoint_pt.getLongitudeE6()/1E6;
String url="https://maps.googleapis.com/maps/api/place/search/xml?";
url=url.concat("&location="+lat+","+lon);
//url=url.concat("&location="+gePoint_pt);
url=url.concat("&radius="+1000);
url=url.concat("&types="+"beauty"+"_"+"salon");
url=url.concat("&name=");
url=url.concat("&sensor="+"true");
url=url.concat("&key=*******");
Log.i("url=========",""+url);
try {
HttpClient client=new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(url));
HttpResponse response = client.execute(request);
HttpEntity resEntity = response.getEntity();
if (resEntity != null)
{
//get web service responce
String res_str=EntityUtils.toString(resEntity);
Log.i("RESPONCE======",""+res_str);
if(res_str!=null)
{
parse(res_str);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
但现在我的问题是,每当我调用这个方法时,我总是得到“零结果”作为美容沙龙的响应。但是,当我在ATM机上尝试同样的方法时,它会给我适当的结果。当我尝试用谷歌地图搜索同样的东西时,它给出了正确的响应.i.e。它展示了我附近所有的美容院。
发布于 2011-10-10 15:07:01
这对我很有效:
http://maps.google.com/maps?q=beauty%20salon&mrt=yp&sll=lat,lon&output=kml
其中,lat,lon是纬度和经度的双重表示。
edit:
这是由OP回答的,使用name
参数而不是types
,这非常奇怪,因为Places文档清楚地说明了使用types
参数。此外,在美国/英国等地也不需要,只有在印度的地方才需要。我希望谷歌能尽快解决这个问题。
https://stackoverflow.com/questions/7709100
复制相似问题