谷歌地图放置 api 在 android 中没有给出正确的结果

发布于 2024-12-08 20:46:40 字数 1417 浏览 0 评论 0原文

在我的应用程序中,我试图获取我当前位置附近美容院的位置。为此,我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ〆星空下的拥抱 2024-12-15 20:46:40

这对我有用:

http:// maps.google.com/maps?q=beauty%20salon&mrt=yp&sll=lat,lon&output=kml

其中 lat、lon 是双纬度和经度。

编辑:这是由OP回答的,使用name参数而不是types,这很奇怪,因为Places文档明确表示使用<代码>类型参数。此外,美国/英国等地区不需要这样做,仅适用于印度的地方。我希望谷歌尽快解决这个问题。

This worked for me :

http://maps.google.com/maps?q=beauty%20salon&mrt=yp&sll=lat,lon&output=kml

where lat, lon is the double latitude and longitude.

edit: This was answered by OP, use the name parameter instead of types, which is very weird because the Places documentation clearly says use the types parameter. Also this is not needed in USA/UK etc, only for places in India. I hope Google fixes this soon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文