当前位置: 首页>>代码示例>>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;未经允许,请勿转载。