Java 自动完成文本并在地图上搜索

Java 自动完成文本并在地图上搜索,java,android,google-maps,android-studio,Java,Android,Google Maps,Android Studio,我使用此代码,可以更改纬度和经度,但当我运行应用程序时,应用程序不会显示我的搜索详细信息 private ArrayList<MyGooglePlaces> getPredictions(String constraint) { //pass your current latitude and longitude to find nearby and ranky=distance means places will be found in ascending

我使用此代码,可以更改纬度和经度,但当我运行应用程序时,应用程序不会显示我的搜索详细信息

 private ArrayList<MyGooglePlaces> getPredictions(String constraint)
    {
        //pass your current latitude and longitude to find nearby and ranky=distance means places will be found in ascending order
        // according to distance
        double latitude=30.7333;
        double longitude=76.7794;
        String API_KEY="AIzaSyByodZEsDBTC-J3brJ39JiYTkqbtJhlSKo";
        String url= "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location="+latitude+","+longitude+"&rankby=distance&name="+constraint+"&key="+API_KEY;
        return getPlaces(url);
private ArrayList getPredictions(字符串约束)
{
//传递您当前的纬度和经度以查找附近,ranky=距离表示将按升序查找位置
//按距离
双纬度=30.7333;
双经度=76.7794;
字符串API_KEY=“AIzaSyByodZEsDBTC-J3brJ39JiYTkqbtJhlSKo”;
字符串url=”https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=“+纬度+”、“+经度+”&rankby=distance&name=“+constraint+”&key=“+API\u key;
返回getPlaces(url);

如何将其修复到我的附近位置???

通过此代码,您可以根据您的位置轻松获得谷歌地图上列出的附近位置列表

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi
                        .getCurrentPlace(mGoogleApiClient, null);
                result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
                    @Override
                    public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
                        ArrayList<String> nearbyPlaces = new ArrayList<>();
                        for (final PlaceLikelihood placeLikelihood : likelyPlaces) {
                            nearbyPlaces.add(placeLikelihood.getPlace().getName().toString());
                            // here, placeLikelihood.getPlace().getName() returns name of nearby places
                        }
                        likelyPlaces.release();
                    }
                });
pendingreult结果=Places.PlaceDetectionApi
.getCurrentPlace(mgoogleapClient,空);
result.setResultCallback(新的ResultCallback(){
@凌驾
public void onResult(PlaceLikelihoodBuffer likelyPlaces){
ArrayList nearbyPlaces=新的ArrayList();
对于(最终位置可能性:可能位置){
添加(place.getPlace().getName().toString());
//这里,placelikelibility.getPlace().getName()返回附近地点的名称
}
likelyPlaces.release();
}
});

您想根据您的位置找到附近的地方吗?是的,我想根据我的位置找到附近的地方检查我的答案。