[英]Auto complete text and search on map
I use this code and I can change latitude and longitude but when I run the app, app doesn't show my search detail 我使用此代码,可以更改纬度和经度,但是当我运行该应用程序时,该应用程序不会显示我的搜索详细信息
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);
How can I fix this to my nearby places ??? 我该如何解决附近的问题???
From this code you can easily get a list of nearby places listed on google maps, according to your location. 通过此代码,您可以根据您的位置轻松获取Google地图上列出的附近地点的列表。
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();
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.