2017-05-01 44 views
0
return "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" 
      +lat+','+lng 
      + "&radius=" +radius 
      + "&types=" + "food,hospital" //??? 
      + "&type=point_of_interest&key=KEY"; 

我怎樣才能得到我附近的所有醫院和食物?我用 「」 &類型=」 + 「食品,醫院」,但是這給了我所有類型的地方靠近我如何使用Google Places API搜索2種特定類型的地點?

謝謝你的答案

回答

0

嘗試使用:。

String types = "food|hospital"; -- the pipe symbol 

在代碼:

String URL = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location="; 
String types = "food|hospital"; 
String key = "your_key"; 
try { 
     placesSearchStr = URL +lat+ "," +lng+ 
         "&radius=1000&sensor=false&types="+URLEncoder.encode(types,"UTF-8")+ 
         "&key="+key; 
     return placesSearchStr; 
    } catch (UnsupportedEncodingException e) { 
     e.printStackTrace(); 
    } 
+0

因此,而不是','我應該使用'|' :) 謝謝! – user3575965

相關問題