本文整理汇总了Java中com.google.android.gms.location.places.Place.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Place.getId方法的具体用法?Java Place.getId怎么用?Java Place.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.location.places.Place
的用法示例。
在下文中一共展示了Place.getId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateGeofencesList
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
/**
* Updates the local {@link ArrayList} of geofences from the data in the passed list
*Uses the place id defined by the API as the geofence object id.
*
* @param places the placeBuffer result of the getPlaceByid call.
*/
public void updateGeofencesList(PlaceBuffer places){
mGeofenceList = new ArrayList<>();
if (places==null || places.getCount()==0) return;
for (Place place: places){
String placeUid = place.getId();
double latitude = place.getLatLng().latitude;
double longitude = place.getLatLng().longitude;
//Build a geofence object
Geofence geofence = new Geofence.Builder()
.setRequestId(placeUid)
.setExpirationDuration(GEOFENCE_TIMEOUT)
.setCircularRegion(latitude,longitude,GEOFENCE_RADIUS)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
.build();
mGeofenceList.add(geofence);
}
}
示例2: onActivityResult
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
/***
* Called when the Place Picker Activity returns back with a selected place (or after canceling)
*
* @param requestCode The request code passed when calling startActivityForResult
* @param resultCode The result code specified by the second activity
* @param data The Intent that carries the result data.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode==PLACE_PICKER_REQUEST&&resultCode==RESULT_OK){
Place place = PlacePicker.getPlace(this,data);
if (place==null){
Log.i(LOG_TAG,"No place selected");
return;
}
String placeName = place.getName().toString();
String placeAddress = place.getAddress().toString();
String placeId = place.getId();
ContentValues values = new ContentValues();
values.put(PlacesContract.PlaceEntry.COLUMN_PLACE_ID,placeId);
getContentResolver().insert(PlacesContract.PlaceEntry.CONTENT_URI,values);
refreshPlacesData();
}
}
示例3: onActivityResult
import com.google.android.gms.location.places.Place; //导入方法依赖的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);
}
示例4: onActivityResult
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public void onActivityResult(final Activity activity, final int requestCode, final int resultCode, final Intent data) {
if (mCallback == null || requestCode != REQUEST_PLACE_PICKER) {
return;
}
response = Arguments.createMap();
if (resultCode == 2) {
response.putString("error", "Google Maps not setup correctly. Did you forget the API key, or enabling the Places API for Android?");
mCallback.invoke(response);
} else if (resultCode == Activity.RESULT_OK) {
final Place place = PlacePicker.getPlace(data, reactContext);
final CharSequence address = place.getAddress();
final LatLng coordinate = place.getLatLng();
final CharSequence name = place.getName();
final CharSequence id = place.getId();
response.putString("address", address.toString());
response.putDouble("latitude", coordinate.latitude);
response.putDouble("longitude", coordinate.longitude);
response.putString("name", name.toString());
response.putString("google_id", id.toString());
mCallback.invoke(response);
} else {
response.putBoolean("didCancel", true);
mCallback.invoke(response);
return;
}
}
示例5: Station
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public Station(Place place){
List<Integer> types = place.getPlaceTypes();
boolean isGasStation = false;
for (Integer i: types){
if(i==Place.TYPE_GAS_STATION){
isGasStation = true;
break;
}
}
if(isGasStation){
id = place.getId();
name = place.getName().toString();
address = place.getAddress().toString();
phoneNumber = place.getPhoneNumber().toString();
Location l = new Location(place.getLatLng().latitude,place.getLatLng().longitude);
location = l;
generalRate = place.getRating();
moneyRate = place.getPriceLevel();
} else {
throw new IllegalArgumentException("Place is not a gas station.");
}
}
示例6: fromPlace
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public static PlaceModel fromPlace(Place place) {
PlaceModel placeModel = new Select().from(PlaceModel.class)
.where(PlaceContract.Columns.GOOGLE_ID + " = ?", place.getId())
.executeSingle();
if (placeModel == null) {
placeModel = new PlaceModel();
placeModel.googleID = place.getId();
placeModel.address = place.getAddress().toString();
placeModel.latitude = place.getLatLng().latitude;
placeModel.longitude = place.getLatLng().longitude;
placeModel.name = place.getName().toString();
placeModel.saveWithAudit();
}
return placeModel;
}
示例7: fromPlace
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
public static PointOfInterest fromPlace(Place place) {
PointOfInterest pointOfInterest = new PointOfInterest();
pointOfInterest.id = place.getId();
pointOfInterest.name = place.getName().toString();
pointOfInterest.address = place.getAddress().toString();
pointOfInterest.latLng = place.getLatLng();
pointOfInterest.phoneNumber = place.getPhoneNumber().toString();
pointOfInterest.latLngBounds = place.getViewport();
return pointOfInterest;
}
示例8: onActivityResult
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Constants.REQUEST_CODE_PLACE_PICKER) {
if (resultCode == Activity.RESULT_OK) {
Place place = PlacePicker.getPlace(data, getActivity());
if (place == null) {
return;
}
// The place picker presents two selection options: "select this location" and
// "nearby places". Only the nearby places selection returns a placeId we can
// submit to the service; the location selection will return a hex-like 0xbeef
// identifier for that position instead, which isn't what we want. Here we check
// if the entire string is hex and clear the placeId if it is.
String id = place.getId();
if (id.startsWith("0x") && id.matches("0x[0-9a-f]+")) {
placeId.setText("");
beaconInstance.placeId = "";
} else {
placeId.setText(id);
beaconInstance.placeId = id;
}
LatLng placeLatLng = place.getLatLng();
latLng.setText(placeLatLng.toString());
beaconInstance.latitude = placeLatLng.latitude;
beaconInstance.longitude = placeLatLng.longitude;
updateBeacon();
} else {
logErrorAndToast("Error loading place picker. Is the Places API enabled? "
+ "See https://developers.google.com/places/android-api/signup for more detail");
}
}
}
示例9: setPlace
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
private void setPlace(Place place) {
if (place == null) {
this.place = null;
} else {
this.place = new LDPlace(place.getName() + "", place.getId(), place.getLatLng().latitude, place.getLatLng().longitude);
}
this.saveData();
}
示例10: onActivityResult
import com.google.android.gms.location.places.Place; //导入方法依赖的package包/类
/**
* Extracts data from PlacePicker result.
* This method is called when an Intent has been started by calling
* {@link #startActivityForResult(android.content.Intent, int)}. The Intent for the
* {@link com.google.android.gms.location.places.ui.PlacePicker} is started with
* {@link #REQUEST_PLACE_PICKER} request code. When a result with this request code is received
* in this method, its data is extracted by converting the Intent data to a {@link Place}
* through the
* {@link com.google.android.gms.location.places.ui.PlacePicker#getPlace(android.content.Intent,
* android.content.Context)} call.
*
* @param requestCode
* @param resultCode
* @param data
*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// BEGIN_INCLUDE(activity_result)
if (requestCode == REQUEST_PLACE_PICKER) {
// This result is from the PlacePicker dialog.
// Enable the picker option
showPickAction(true);
if (resultCode == Activity.RESULT_OK) {
/* User has picked a place, extract data.
Data is extracted from the returned intent by retrieving a Place object from
the PlacePicker.
*/
final Place place = PlacePicker.getPlace(data, getActivity());
/* A Place object contains details about that place, such as its name, address
and phone number. Extract the name, address, phone number, place ID and place types.
*/
final CharSequence name = place.getName();
final CharSequence address = place.getAddress();
final CharSequence phone = place.getPhoneNumber();
final String placeId = place.getId();
String attribution = PlacePicker.getAttributions(data);
if(attribution == null){
attribution = "";
}
// Update data on card.
getCardStream().getCard(CARD_DETAIL)
.setTitle(name.toString())
.setDescription(getString(R.string.detail_text, placeId, address, phone,
attribution));
// Print data to debug log
Log.d(TAG, "Place selected: " + placeId + " (" + name.toString() + ")");
// Show the card.
getCardStream().showCard(CARD_DETAIL);
} else {
// User has not selected a place, hide the card.
getCardStream().hideCard(CARD_DETAIL);
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
// END_INCLUDE(activity_result)
}