当前位置: 首页>>代码示例>>Java>>正文


Java PlaceAutocomplete.getPlace方法代码示例

本文整理汇总了Java中com.google.android.gms.location.places.ui.PlaceAutocomplete.getPlace方法的典型用法代码示例。如果您正苦于以下问题:Java PlaceAutocomplete.getPlace方法的具体用法?Java PlaceAutocomplete.getPlace怎么用?Java PlaceAutocomplete.getPlace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.location.places.ui.PlaceAutocomplete的用法示例。


在下文中一共展示了PlaceAutocomplete.getPlace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleSearch

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
private void handleSearch(int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        Place place = PlaceAutocomplete.getPlace(getActivity(), data);
        Location loc = LocationAdapter.getLocation(place.getLatLng());
        try {
            CivifyMap.getInstance().disableLocation();
            CivifyMap.getInstance().setAutoCenter(false);
            mLastZoom = CivifyMap.getInstance().getCurrentCameraPosition().zoom;

            CivifyMap.getInstance().center(loc, CivifyMap.DEFAULT_ZOOM, true);
            mSarchCenterSnackbar = Snackbar.make(getView(),
                    getString(R.string.search_disable_center), Snackbar.LENGTH_INDEFINITE);
            mSarchCenterSnackbar.show();
        } catch (MapNotLoadedException ignore) {
            Snackbar.make(getView(), getString(R.string.error_ocurred),
                    Snackbar.LENGTH_SHORT).show();
        }
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
        Snackbar.make(getView(), getString(R.string.error_ocurred),
                Snackbar.LENGTH_SHORT).show();
    }
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:23,代码来源:NavigateFragment.java

示例2: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case PLACE_AUTOCOMPLETE_REQUEST_CODE:
            if (resultCode == RESULT_OK) {
                Place place = PlaceAutocomplete.getPlace(getActivity(), data);
                showToast(place.getAddress().toString());
                Log.i("TAG", "Place: " + place.getName());
            } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
                Status status = PlaceAutocomplete.getStatus(getActivity(), data);
                // TODO: Handle the error.
                Log.i("TAG", status.getStatusMessage());
                showToast(status.getStatusMessage());
            } else if (resultCode == RESULT_CANCELED) {
                // The user canceled the operation.
                showToast("Operation canceled");
            }
            break;
    }
}
 
开发者ID:Balthair94,项目名称:AppGoogleMaps,代码行数:21,代码来源:DirectionsDetailFragment.java

示例3: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

	if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
		if (resultCode == RESULT_OK) {
			// Move camera to that place and add normal marker
			Place place = PlaceAutocomplete.getPlace(this, data);
			this.googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(place.getLatLng(), 17), 1000, null);
			this.googleMap.addMarker(new MarkerOptions().position(place.getLatLng()));
			// Set text on "edit text"
			binding.placeSearch.setText(place.getName());
		} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
			Status status = PlaceAutocomplete.getStatus(this, data);
			Log.w(TAG, status.getStatusMessage());
		} else if (resultCode == RESULT_CANCELED) {
			// The user canceled the operation -- clear text
			binding.placeSearch.setText("");
		}
	}
}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:21,代码来源:MapActivity.java

示例4: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getAddress());
            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:20,代码来源:NewJournalActivity.java

示例5: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.location = pl.getName().toString();
            currentTrip.lat = pl.getLatLng().latitude;
            currentTrip.lng = pl.getLatLng().longitude;
            currentTrip.placeId = pl.getId();

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:25,代码来源:NewJournalActivity.java

示例6: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place pl = PlaceAutocomplete.getPlace(this, data);
            location.setText(pl.getName());
            currentTrip.setLocation(pl.getName().toString());
            currentTrip.setLat(pl.getLatLng().latitude);
            currentTrip.setLng(pl.getLatLng().longitude);
            currentTrip.setPlaceId(pl.getId());

            Log.i(TAG, "onActivityResult: " + pl.getName() + "/" + pl.getAddress());

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status stat = PlaceAutocomplete.getStatus(this, data);
            Log.d(TAG, "onActivityResult: ");
        }
        else if (requestCode == RESULT_CANCELED){
            System.out.println("Cancelled by the user");
        }
    }
    else
        super.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:25,代码来源:NewJournalActivity.java

示例7: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    authorizer.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == LOCATION_ENABLE_REQUEST_CODE) {
            new Handler().post(() -> {
                toiletListPresenter.locationEnabledSuccess();
            });
        }
        if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
            Place place = PlaceAutocomplete.getPlace(getActivity(), data);
            toiletListPresenter.citySelected(place);
        }
    }


}
 
开发者ID:lvanyal,项目名称:directly,代码行数:19,代码来源:ToiletListFragment.java

示例8: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(getContext(), data);
            Log.i(MainActivity.TAG, "Place: " + place.getName());


            weatherLat.update(place.getLatLng().latitude);
            weatherLng.update(place.getLatLng().longitude);
            weatherCity.update(place.getName().toString());

            sWeatherCity.setSubHeaderText(weatherCity.value);

            // don't change the order of the following two lines
            updateWidgetProperty("lat", weatherLat.value);
            updateWidgetProperty("lng", weatherLng.value);

        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(getContext(), data);
            // TODO: Handle the error.
            Log.i(MainActivity.TAG, status.getStatusMessage());

        }
    }
}
 
开发者ID:dan-silver,项目名称:cast-dashboard-android-app,代码行数:27,代码来源:WeatherSettings.java

示例9: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    //autocompleteFragment.onActivityResult(requestCode, resultCode, data);
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            Log.i("1", "Place:" + place.toString());
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            Log.i("1", status.getStatusMessage());
        } else if (requestCode == RESULT_CANCELED) {

        }
    }
}
 
开发者ID:sanidhya09,项目名称:androidprojectbase,代码行数:17,代码来源:PlacesAutoCompleteSample.java

示例10: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Log.d(TAG, "resultCode=" + Integer.toString(resultCode));
    //final LocationSettingsStates states = LocationSettingsStates.fromIntent(data);
    switch (resultCode) {
        case Activity.RESULT_OK: {
            // All required changes were successfully made
            // Log.i(TAG, "Location enabled by user!");
            if(requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE){
                Place place = PlaceAutocomplete.getPlace(this, data);
                Log.i(TAG, "Place: " + place.getLatLng());
                createMarkerLatLng(convert(place.getLatLng().latitude,place.getLatLng().longitude),place.getLatLng());
                Toast.makeText(getApplicationContext(),place.getName(),Toast.LENGTH_SHORT).show();
            }else {
                Toast.makeText(getApplicationContext(), "Location Enabled", Toast.LENGTH_SHORT).show();
                enableMyLocation();
                startActivity(new Intent(MapsActivity.this, MapsActivity.class));
            }break;
        }
        case Activity.RESULT_CANCELED: {
            // The user was asked to change settings, but chose not to
            //TODO: display the below code
            Toast.makeText(getApplicationContext(),"No Connection Found",Toast.LENGTH_SHORT).show();
            /*Snackbar snackbar = Snackbar.make(, "No Connection Found", Snackbar.LENGTH_INDEFINITE)
                    .setAction("GO OFFLINE", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {

                        }
                    });
            */// Log.i(TAG, "Location not enabled, user cancelled.");
            break;
        }
        default: {
            // Log.e(TAG, "Error in selecting the button in Auto-Switch On Location Feature");
            break;
        }
    }
}
 
开发者ID:addy-org,项目名称:Addy-Android,代码行数:40,代码来源:MapsActivity.java

示例11: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
    if (resultCode == RESULT_OK) {
      Place place = PlaceAutocomplete.getPlace(this, data);
      Toast.makeText(this, "Place picked: " + place.getName(), Toast.LENGTH_SHORT).show();
      launchDisplay(place);
    } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
      Status status = PlaceAutocomplete.getStatus(this, data);
      Log.i(TAG, status.getStatusMessage());
    }
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-hud-demo,代码行数:14,代码来源:GeocodeActivity.java

示例12: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case LOCATION_NAME_REQUEST:

            if (resultCode == RESULT_OK) {
                Log.d(TAG, "Add city name request to queue");

                Place place = PlaceAutocomplete.getPlace(getActivity(), data);
                LatLng coords = place.getLatLng();

                cityAddQueue.add(new CityCoordinatesModel(place.getName().toString(),
                        coords.latitude, coords.longitude));

                if (!isRefreshing && !isAddQueueHandling) {
                    Log.d(TAG, "Start new city name request queue");

                    makeCityNameWeatherRequest();
                }

                isAddQueueHandling = true;

            } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
                Status status = PlaceAutocomplete.getStatus(getActivity(), data);

                Log.d(TAG, status.getStatusMessage());
            }

            break;
    }
}
 
开发者ID:farukydnn,项目名称:WeatherPlus,代码行数:32,代码来源:CityListFragment.java

示例13: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == RESULT_OK) {
        if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
            Place place = PlaceAutocomplete.getPlace(getActivity(), intent);
            newToiletPresenter.placeSelected(place);
        }
    }
}
 
开发者ID:lvanyal,项目名称:directly,代码行数:11,代码来源:NewToiletFragment.java

示例14: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
/**
 * Receives the data from {@link PlaceAutocomplete} search intent and moves the map to that location
 *
 * @param requestCode
 * @param resultCode
 * @param data
 * @see PlaceAutocomplete
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_SELECT_PLACE) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            Location location = new Location("place");
            location.setLatitude(place.getLatLng().latitude);
            location.setLongitude(place.getLatLng().longitude);
            mapUtil.moveMap(mMap, location, 15);
        }
    }
}
 
开发者ID:CMPUT301F16T02,项目名称:Dryver,代码行数:22,代码来源:ActivityRequestMap.java

示例15: onActivityResult

import com.google.android.gms.location.places.ui.PlaceAutocomplete; //导入方法依赖的package包/类
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_SELECT_PLACE) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            this.onPlaceSelected(place);
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            this.onError(status);
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
开发者ID:Truiton,项目名称:PlaceApiAutocompleteWidget,代码行数:13,代码来源:MainActivity.java


注:本文中的com.google.android.gms.location.places.ui.PlaceAutocomplete.getPlace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。