當前位置: 首頁>>代碼示例>>Java>>正文


Java Place類代碼示例

本文整理匯總了Java中com.google.android.gms.location.places.Place的典型用法代碼示例。如果您正苦於以下問題:Java Place類的具體用法?Java Place怎麽用?Java Place使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Place類屬於com.google.android.gms.location.places包,在下文中一共展示了Place類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onActivityResult

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (resultCode == RESULT_OK) {
            Place place = PlacePicker.getPlace(data, this);
            Intent intent = new Intent(this, InfoActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("name", place.getName());
            intent.putExtra("lat", place.getLatLng().latitude);
            intent.putExtra("lng", place.getLatLng().longitude);
            startActivity(intent);
            finish();
        } else finish();
    }

}
 
開發者ID:hwhung0111,項目名稱:2017NASA_NCTUBeach,代碼行數:17,代碼來源:LocationSelectActivity.java

示例2: onLocationPermissionGranted

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
@Override
protected void onLocationPermissionGranted() {
    compositeSubscription = new CompositeSubscription();
    compositeSubscription.add(reactiveLocationProvider.getPlaceById(placeId)
            .subscribe(new Action1<PlaceBuffer>() {
                @Override
                public void call(PlaceBuffer buffer) {
                    Place place = buffer.get(0);
                    if (place != null) {
                        placeNameView.setText(place.getName());
                        placeLocationView.setText(place.getLatLng().latitude + ", " + place.getLatLng().longitude);
                        placeAddressView.setText(place.getAddress());
                    }
                    buffer.release();
                }
            }));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:PlacesResultActivity.java

示例3: 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);
    }
}
 
開發者ID:samagra14,項目名稱:Shush,代碼行數:24,代碼來源:Geofencing.java

示例4: 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();
    }
}
 
開發者ID:samagra14,項目名稱:Shush,代碼行數:27,代碼來源:MainActivity.java

示例5: onResult

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
@Override
public void onResult(PlaceBuffer places) {
    if (!places.getStatus().isSuccess()) {
        places.release();
        return;
    }
    try {
        final Place place = places.get(0);
        if (Preferences.getInstance(SearchActivity.this).isLogged()) {
            searchPresenter.getNearStations(place.getLatLng());
            places.release();
        } else {
            Intent returnIntent = new Intent();
            returnIntent.putExtra(MapFragment.LATITUDE_SEARCH, place.getLatLng().latitude);
            returnIntent.putExtra(MapFragment.LONGITUDE_SEARCH, place.getLatLng().longitude);
            places.release();
            setResult(Activity.RESULT_OK, returnIntent);
            finish();
        }
    } catch (Throwable throwable) {
        resultsRecyclerView.setVisibility(View.GONE);
        emptyTextView.setVisibility(View.VISIBLE);
        emptyTextView.setText(getString(R.string.error_generic));
    }
}
 
開發者ID:Mun0n,項目名稱:MADBike,代碼行數:26,代碼來源:SearchActivity.java

示例6: handleSearch

import com.google.android.gms.location.places.Place; //導入依賴的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

示例7: onSuggestResult

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
@Override
public void onSuggestResult(final Place place, final AutoCompleteTextView act) {
	final LatLng placelatlng=place.getLatLng();
	if (!isNavigationReady() && (addr_from.getText().length() < 1 || addr_to.getText().length() < 1))
		gmaps.animateCamera(CameraUpdateFactory.newLatLng(place.getLatLng()), 1000, new GoogleMap.CancelableCallback(){
				@Override
				public void onFinish() {
					setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
				}

				@Override
				public void onCancel() {
					setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
				}
			});
	else setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
 
開發者ID:agusibrahim,項目名稱:go-jay,代碼行數:18,代碼來源:MainActivity.java

示例8: onActivityResult

import com.google.android.gms.location.places.Place; //導入依賴的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

示例9: setCurrentLocation

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
/**
 * Set current location from map
 * TODO: Faire mieux la difference entre une location exacte et une
 *
 * @param location the location returned from the map picker
 */
public void setCurrentLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.currentLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.currentLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.currentLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  currentLocation.setText(elephant.currentLoc.format());
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:24,代碼來源:AddProfilFragment.java

示例10: setBirthLocation

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
/**
 * Set birth location from map
 *
 * @param location the location returned from the map picker
 */
public void setBirthLocation(Intent data) {
  final Place place = PlacePicker.getPlace(getActivity(), data);
  Geocoder geocoder = new Geocoder(getActivity());

  try {
    List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
    elephant.birthLoc.cityName = addresses.get(0).getAddressLine(0);
    if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
      elephant.birthLoc.districtName = addresses.get(0).getSubAdminArea();
    }
    elephant.birthLoc.provinceName = addresses.get(0).getAdminArea();
  } catch (IOException e) {
    e.printStackTrace();
  }

  birthLocation.setText(elephant.birthLoc.format());
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:23,代碼來源:AddProfilFragment.java

示例11: setRegistrationLocation

import com.google.android.gms.location.places.Place; //導入依賴的package包/類
public void setRegistrationLocation(Intent data) {

    final Place place = PlacePicker.getPlace(getActivity(), data);
    Geocoder geocoder = new Geocoder(getActivity());

    try {
      List<Address> addresses = geocoder.getFromLocation(place.getLatLng().latitude, place.getLatLng().longitude, 1);
      elephant.registrationLoc.cityName = addresses.get(0).getAddressLine(0);
      if (!addresses.get(0).getAddressLine(0).equals(addresses.get(0).getSubAdminArea())) {
        elephant.registrationLoc.districtName = addresses.get(0).getSubAdminArea();
      }
      elephant.registrationLoc.provinceName = addresses.get(0).getAdminArea();
    } catch (IOException e) {
      e.printStackTrace();
    }

    registrationLocation.setText(elephant.registrationLoc.format());
  }
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:19,代碼來源:AddRegistrationFragment.java

示例12: 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) {
			// 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

示例13: 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.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

示例14: 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);
}
 
開發者ID:gvsucis,項目名稱:mobile-app-dev-book,代碼行數:25,代碼來源:NewJournalActivity.java

示例15: 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.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


注:本文中的com.google.android.gms.location.places.Place類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。