gpt4 book ai didi

android - 如何按 PlaceType 过滤 Place Picker 的结果?

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:15:28 25 4
gpt4 key购买 nike

此时地点选取器显示 map ,并在 map 上标记了所有地点。地点列表位于屏幕底部。

如果我可以按地点类型过滤地点,那就太好了。

例如, map 和列表只会显示附近的出租车站。

我的java代码:

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.widget.Toast;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;


public class PlacesAPIActivity extends AppCompatActivity {

private int PLACE_PICKER_REQUEST = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_places_api);

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
Intent intent;
try {
intent = builder.build(getApplicationContext());
startActivityForResult(intent, PLACE_PICKER_REQUEST);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_place_api, menu);

return true;
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_PICKER_REQUEST) {
if (resultCode == RESULT_OK) {

Place place = PlacePicker.getPlace(data , this) ;

String toastMsg = String.format("Place: %s %s", place.getName(), place.getPhoneNumber());
Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show();
}
}
}

}

我的 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:background="@drawable/bg_gradient">

最佳答案

此功能当前不可用。您可以关注这些 Unresolved 问题以获取更新:

Issue 8484: Filter Place Picker by PlaceType

关于android - 如何按 PlaceType 过滤 Place Picker 的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33059676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com