【发布时间】:2015-05-29 14:12:20
【问题描述】:
我目前正在 Android Studio 1.1.0 中开发一个应用程序,并且我已经实现了 Google Maps API,我可以从中检索用户当前位置,但我想将其转换为地址。我可以在 MapsActivity.java 文件中使用以下代码吗?
function getReverseGeocodingData(lat, lng) {
var latlng = new google.maps.LatLng(lat, lng);
// This is making the Geocode request
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'latLng': latlng }, function (results, status) {
if (status !== google.maps.GeocoderStatus.OK) {
alert(status);
}
// This is checking to see if the Geoeode Status is OK before proceeding
if (status == google.maps.GeocoderStatus.OK) {
console.log(results);
var address = (results[0].formatted_address);
}
});
}
任何帮助将不胜感激。对 Android Studio 来说还是比较新的
【问题讨论】:
标签: java android google-maps geocoding reverse-geocoding