android.location.Address.hasLatitude()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(126)

本文整理了Java中android.location.Address.hasLatitude()方法的一些代码示例,展示了Address.hasLatitude()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.hasLatitude()方法的具体详情如下:
包路径:android.location.Address
类名称:Address
方法名:hasLatitude

Address.hasLatitude介绍

暂无

代码示例

代码示例来源:origin: square/assertj-android

  1. public AddressAssert hasNoLatitude() {
  2. isNotNull();
  3. assertThat(actual.hasLatitude()) //
  4. .overridingErrorMessage("Expected to not have latitude but did.") //
  5. .isFalse();
  6. return this;
  7. }

代码示例来源:origin: square/assertj-android

  1. public AddressAssert hasLatitude() {
  2. isNotNull();
  3. assertThat(actual.hasLatitude()) //
  4. .overridingErrorMessage("Expected to have latitude but did not.") //
  5. .isTrue();
  6. return this;
  7. }

代码示例来源:origin: stackoverflow.com

  1. if(Geocoder.isPresent()){
  2. try {
  3. String location = "theNameOfTheLocation";
  4. Geocoder gc = new Geocoder(this);
  5. List<Address> addresses= gc.getFromLocationName(location, 5); // get the found Address Objects
  6. List<LatLng> ll = new ArrayList<LatLng>(addresses.size()); // A list to save the coordinates if they are available
  7. for(Address a : addresses){
  8. if(a.hasLatitude() && a.hasLongitude()){
  9. ll.add(new LatLng(a.getLatitude(), a.getLongitude()));
  10. }
  11. }
  12. } catch (IOException e) {
  13. // handle the exception
  14. }
  15. }

代码示例来源:origin: com.squareup.assertj/assertj-android

  1. public AddressAssert hasNoLatitude() {
  2. isNotNull();
  3. assertThat(actual.hasLatitude()) //
  4. .overridingErrorMessage("Expected to not have latitude but did.") //
  5. .isFalse();
  6. return this;
  7. }

代码示例来源:origin: com.squareup.assertj/assertj-android

  1. public AddressAssert hasLatitude() {
  2. isNotNull();
  3. assertThat(actual.hasLatitude()) //
  4. .overridingErrorMessage("Expected to have latitude but did not.") //
  5. .isTrue();
  6. return this;
  7. }

代码示例来源:origin: stackoverflow.com

  1. if(addressList != null && addressList.size() > 0) {
  2. // location exists
  3. Address address = addressList.get(0);
  4. System.out.println(address);
  5. if(address.hasLatitude() && address.hasLongitude()){
  6. coordinates[0] = address.getLatitude();
  7. coordinates[1] = address.getLongitude();
  8. this.canGetCoordinates = true;
  9. this.isLocationValid = true;
  10. System.out.println(coordinates[0]);
  11. System.out.println(coordinates[1]);
  12. }
  13. } else {
  14. // location does not exist
  15. }

代码示例来源:origin: stackoverflow.com

  1. List<Address> addressList = geoCoder.getFromLocationName(cityName, 1);
  2. Address address = addressList.get(0);
  3. if(address.hasLatitude() && address.hasLongitude()){
  4. double selectedLat = address.getLatitude();
  5. double selectedLng = address.getLongitude();
  6. }

代码示例来源:origin: stackoverflow.com

  1. if(Geocoder.isPresent()){
  2. try {
  3. String location = "MyLocation";
  4. Geocoder gcoder = new Geocoder(this);
  5. List<Address> addresses= gcoder.getFromLocationName(location, 5); // get the found Address Objects
  6. List<LatLng> ll = new ArrayList<LatLng>(addresses.size()); // A list to save the coordinates if they are available
  7. for(Address addr : addresses){
  8. if(addr.hasLatitude() && addr.hasLongitude()){
  9. ll.add(new LatLng(addr.getLatitude(), addr.getLongitude();
  10. }
  11. }
  12. } catch (IOException e) {
  13. // handle the exception
  14. }
  15. }

代码示例来源:origin: stackoverflow.com

  1. Geocoder g = new Geocoder(this);
  2. List<Address> addressList = null;
  3. String searchRoad = "Insert Road Name Here!";
  4. try {
  5. addressList = g.getFromLocationName(searchRoad, 1);
  6. } catch (IOException e) {
  7. Toast.makeText(this, "Location not found", Toast.LENGTH_SHORT)
  8. .show();
  9. e.printStackTrace();
  10. } finally {
  11. Address address = addressList.get(0);
  12. if (address.hasLatitude() && address.hasLongitude()) {
  13. double selectedLat = address.getLatitude();
  14. double selectedLng = address.getLongitude();
  15. LatLng Road = new LatLng(selectedLat, selectedLng);
  16. Marker Custom = map.addMarker(new MarkerOptions()
  17. .position(searchedRoad).title("Here is the road location")
  18. .snippet("Hon the lads"));
  19. }

相关文章