我正在使用Google Places Apis过滤特定城市内的结果.我可以过滤结果.但它也会显示该城市的结果.例如,如果我设置DELHI城市的LatLngBounds并在城市NEWYORK中搜索位置.它也给了我纽约市的结果(但是NEWYORK的LatLng并不在于DELHI).
如何将结果限制在特定城市?
这是我的PlaceAutoCompleteAdapter类
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.data.DataBufferUtils;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.AutocompletePrediction;
import com.google.android.gms.location.places.AutocompletePredictionBuffer;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.LatLngBounds;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
public class PlaceAutocompleteAdapter
extends ArrayAdapter<AutocompletePrediction> implements Filterable {
private ArrayList<AutocompletePrediction> mResultList;
private GoogleApiClient mGoogleApiClient;
private LatLngBounds mBounds;
private AutocompleteFilter mPlaceFilter;
public PlaceAutocompleteAdapter(Context context, GoogleApiClient googleApiClient,
LatLngBounds bounds, AutocompleteFilter filter) {
super(context,R.layout.simple_expandble_text_view_item, R.id.text1);
mGoogleApiClient = googleApiClient;
mBounds = …Run Code Online (Sandbox Code Playgroud) 这是第一次使用谷歌地图API和谷歌地方API.我正在做一个演示应用程序,显示最靠近用户位置的列表医院(例如)以及到每个医院的路线.我能够通过下面的代码获取用户的位置:
public class MainActivity extends ActionBarActivity {
private GoogleMap map;
UiSettings mapSettings;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
if (map != null) {
// map.addMarker(new MarkerOptions().position(myLocation).title("Start"));
map.setMyLocationEnabled(true);
mapSettings = map.getUiSettings();
mapSettings.setScrollGesturesEnabled(true);
mapSettings.setZoomControlsEnabled(true);
}
}
}
Run Code Online (Sandbox Code Playgroud)
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:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的问题如何使用google places API获取医院列表并显示它们.任何帮助,提示,演练或教程都将被认可.谢谢.
android google-maps google-places-api google-maps-android-api-2