[英]Customize google places to find restaurants nearby
I am building an android app to find all the restaurant nearby. 我正在构建一个Android应用程序来查找附近的所有餐厅。 im taking the help of google places api to do so but i am not able to customize it to shown only restaurants.
即时通过google places api的帮助这样做,但我无法自定义它只显示餐馆。 So please help and thanks in advance.
所以请提前帮助和感谢。
public class MainActivity extends FragmentActivity
implements OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button) findViewById(R.id.button);
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
.getCurrentPlace(mGoogleApiClient, null);
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
for (PlaceLikelihood placeLikelihood : likelyPlaces) {
Toast.makeText(MainActivity.this, "Place " + placeLikelihood.getPlace().getName(), Toast.LENGTH_LONG).show();
}
likelyPlaces.release();
}
});
Try doing this using 尝试使用
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&keyword=cruise&key=YOUR_API_KEY https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=500&type=restaurant&keyword=cruise&key=YOUR_API_KEY
For more reference goto, https://developers.google.com/places/web-service/search 有关更多参考, 请访问https://developers.google.com/places/web-service/search
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.