【问题标题】:Get geocode from autocomplete places从自动填充位置获取地理编码
【发布时间】:2014-09-23 17:14:34
【问题描述】:
【问题讨论】:
标签:
android
google-maps
google-geocoder
【解决方案1】:
utf8s = location.getBytes("UTF-8");
String place = new String(utf8s, "UTF-8");
place = place.trim().replace(" ", "+");
HttpGet request =
new HttpGet("https://maps.googleapis.com/maps/api/geocode/json?address="+place+",+CA&key=AIzaSyAXDKR0cSN7kp4tfuUspGZt-zTW5IAa6hM");
result = httpclient.execute(request, handler);
JSONObject response = new JSONObject(result);
JSONObject geometry = response.getJSONArray("results").getJSONObject(0).getJSONObject("geometry");
JSONObject location= geometry.getJSONObject("location");