【发布时间】:2016-01-17 10:16:39
【问题描述】:
我只使用了浏览器密钥和安卓密钥,但它不起作用.... 我需要使用多少个不同的键来进行自动提示并从中获取 LatLng 将在建议中放置名称。
private String getAutoCompleteUrl(String place) {
// Obtain browser key from https://code.google.com/apis/console
String key = "key=AIzaSyAVYq6kcBUABAtMIDil-8GDoDvWMi3QLnE";
// place to be be searched
String input = "input=" + place;
// place type to be searched
String types = "types=geocode";
// Sensor enabled
String sensor = "sensor=false";
// Building the parameters to the web service
String parameters = input + "&" + types + "&" + sensor + "&" + key;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/place/autocomplete/"
+ output + "?" + parameters;
return url;
}
private String getPlaceDetailsUrl(String ref) {
// Obtain browser key from https://code.google.com/apis/console
String key = "key=AIzaSyAVYq6kcBUABAtMIDil-8GDoDvWMi3QLnE";
// reference of place
String reference = "reference=" + ref;
// Sensor enabled
String sensor = "sensor=false";
// Building the parameters to the web service
String parameters = reference + "&" + sensor + "&" + key;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/place/details/"
+ output + "?" + parameters;
Log.d("url:",url);
return url;
}
【问题讨论】:
标签: android google-maps google-maps-api-3 google-places-api