如何使用地点选择器将附近的巴士站带到当前位置

how to get nearby bus stops to current location using place picker

I dont know how to fetch result, only of nearby bus stops.I tried to go through place picker documentation for help.But it shows all the nearby places ,if i only need bus stops what to do.It returns all nearby places how to get only what i want

import android.Manifest;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.widget.Toast;

import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlacePicker;
import com.google.android.gms.maps.model.LatLngBounds;

import transportation.lumiumdesign.com.transportation.R;

/**
 * 
 * It contains a place picker to detect current location and nearby bus stops to it.
 */

public class CurrentLocMap extends FragmentActivity {

    int PLACE_PICKER_REQUEST = 1;//Predefined req_code

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

        PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();

/**        Intent Builder will set current location of deviceif not provided
 **/
        try {
            startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST);
        } catch (GooglePlayServicesRepairableException e) {
            e.printStackTrace();
        } catch (GooglePlayServicesNotAvailableException e) {
            e.printStackTrace();
        }
    }

    //onActivityResult will launch place picker
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == PLACE_PICKER_REQUEST) {
            if (resultCode == RESULT_OK) {
                Place place = PlacePicker.getPlace(this, data);

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

}

不幸的是,即使像 测试的那样扩展地点选择器 Class 也无法进行过滤。

您还可以关注这两个未解决的问题以获取 共享的更新:

但是你可以尝试使用,place autocomplete

The autocomplete service in the Google Places API for Android returns place predictions in response to user search queries. As the user types, the autocomplete service returns suggestions for places such as businesses, addresses and points of interest.

限制自动完成结果

You can set the autocomplete widget to bias results to a specific geographic region, and/or filter the results to one or more place types.

To filter autocomplete results to a specific place type, call AutocompleteFilter.Builder to create a new AutocompleteFilter, calling setTypeFilter() to set the filter to use. Then, pass the filter to a fragment or intent.

代码示例:

AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
.build();

Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_FULLSCREEN)
.setFilter(typeFilter)
.build(this);