谷歌地图放置 api 在 android 中没有给出正确的结果
在我的应用程序中,我试图获取我当前位置附近美容院的位置。为此,我使用 google place 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();
}
}
,但现在我的问题是,每当我调用此方法时,我总是得到“零结果”作为美容院的响应。但是当我在自动取款机上尝试同样的操作时,它给了我正确的结果。当我尝试使用谷歌地图搜索相同的内容时,它给了我正确的响应。即它显示了我附近的所有美容院。
In my app I'm trying to get location of beauty salons near my current location. For this purpose I'm using google places API. As mentioned in the link I'm trying to get all information about beauty salon near by me. For this I'm using following code
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();
}
}
But now my problem is,whenever I call this method I always get "zero-result" as a response for beauty salons. But when I try the same for atm machines it gives me proper results. When I try to search same things using google map,it gives me proper response .i.e. It displays all the beauty salons near by me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用:
其中 lat、lon 是双纬度和经度。
编辑:
这是由OP回答的,使用name
参数而不是types
,这很奇怪,因为Places文档明确表示使用<代码>类型参数。此外,美国/英国等地区不需要这样做,仅适用于印度的地方。我希望谷歌尽快解决这个问题。This worked for me :
where lat, lon is the double latitude and longitude.
edit:
This was answered by OP, use thename
parameter instead oftypes
, which is very weird because the Places documentation clearly says use thetypes
parameter. Also this is not needed in USA/UK etc, only for places in India. I hope Google fixes this soon.