Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android-如何使用字符串地址而不是位置ID获取GooglePlaces数据?_Java_Android_Google Maps_Google Places Api - Fatal编程技术网

Java Android-如何使用字符串地址而不是位置ID获取GooglePlaces数据?

Java Android-如何使用字符串地址而不是位置ID获取GooglePlaces数据?,java,android,google-maps,google-places-api,Java,Android,Google Maps,Google Places Api,有没有一种方法可以只使用给定的地址获取GooglePlaces数据(如经度、纬度、评级、姓名、电话号码等) 因为我有一个很长的列表,就像一个很长的地址列表。我需要在谷歌地图上标出那个地址,为了做到这一点,我需要先从谷歌那里获取DOS信息。你可以通过地址获得纬度和经度。你的密码 public GeoPoint getLocationFromAddress(String strAddress){ Geocoder coder = new Geocoder(this); List<Addres

有没有一种方法可以只使用给定的地址获取GooglePlaces数据(如经度、纬度、评级、姓名、电话号码等)


因为我有一个很长的列表,就像一个很长的地址列表。我需要在谷歌地图上标出那个地址,为了做到这一点,我需要先从谷歌那里获取DOS信息。

你可以通过地址获得纬度和经度。你的密码

public GeoPoint getLocationFromAddress(String strAddress){

Geocoder coder = new Geocoder(this);
List<Address> address;
GeoPoint p1 = null;

try {
    address = coder.getFromLocationName(strAddress,5);
    if (address==null) {
       return null;
    }
    Address location=address.get(0);
    location.getLatitude();
    location.getLongitude();

p1 = new GeoPoint((double) (location.getLatitude() * 1E6),
                  (double) (location.getLongitude() * 1E6));

return p1;
}
}

您可以使用Android或API来实现这一点

注意,使用Google Places API有一些问题:谢谢,它可以获取位置的坐标,但我仍然需要获取placeID。
compile 'com.google.android.gms:play-services-places:+.'