Android的获得纬度和放大器;长从谷歌地址 [英] Android get lat&long from google address
本文介绍了Android的获得纬度和放大器;长从谷歌地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已实施谷歌广场API
自动填充功能为我的应用程序是这样的:的 https://developers.google.com/places/training/autocomplete-android
I have implemented Google Place API
autocomplete functionality for my application like this: https://developers.google.com/places/training/autocomplete-android
没有,它只是使一个吐司
使用该地址。
No it just makes a Toast
with that address.
我怎样才能获得纬度
和经度
从选定的地址?
How can I get the latitude
and longitude
from the selected address?
推荐答案
如果有帮助,我最近建立了一个库在Java中对谷歌Places API的。
If it helps, I've recently created a library in Java for Google Places API.
自动完成是简单:
GooglePlaces client = new GooglePlace("apiKey");
List<Prediction> predictions = client.getPlacePredictions("Empire");
for (Prediction prediction : predictions) {
String description = prediction.getDescription();
// etc etc
}
和从地址获取经纬度就是这么简单。
And getting a latitude-longitude from an address is as simple as.
List<Place> places = client.getPlacesByQuery(address, GooglePlaces.MAXIMUM_RESULTS);
for (Place place : places) {
if (place.getAddress().equals(address)) {
double lat = place.getLatitude();
double lng = place.getLongitude();
}
}
https://github.com/windy1/google-places-api-java
这篇关于Android的获得纬度和放大器;长从谷歌地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文