2011-10-10 71 views
1

在我的應用程序,我試圖讓美容院的位置在我目前的位置附近。爲此,我使用Google Places API。正如鏈接中提到的,我試圖通過我獲得關於美容院的所有信息。對於這個我用下面的代碼谷歌地圖的地方api沒有給出適當的結果在android

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。它顯示了我附近的所有美容院。

回答

2

這爲我工作:

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

那裏緯度,經度是雙經度和緯度。

edit:這是由OP回答的,使用name參數而不是types,這非常奇怪,因爲Places文檔明確指出使用types參數。這在美國/英國等地也是不需要的,只適用於印度的地方。我希望Google很快解決這個問題。

+0

@reno ...謝謝你的迴應......但是在API文檔中他們提到了beauty_salon在支持的類型部分......請問爲什麼我用它...你可以給我更詳細的介紹.. .bcoz我無法打開網址你有提到.... – android

+0

你是對的,我檢查了文檔。你能告訴我你的拉特嗎?我用過的URL給出了一個類似於xml的kml。這是Google地球可以打開的文件。 – Reno

+0

https://maps.googleapis.com/maps/api/place/search/xml?&location=19.169255,72.959416&radius=1000&types=beauty salon&name =&sensor = true&key = AIzaSyCALnYwpK5B90jgiSG2G0O4F5-dZz5gxEI ........這是我的網址..它給我零結果作爲迴應... – android