开发者

google map places api not giving proper results in android

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜