Kri*_*hna 14 gps android google-maps
我正在开发一个应用程序,其中我在我的Android设备中获得纬度,经度并将它们发布到Web服务器.
在网络应用程序中,我在谷歌地图的帮助下显示位置详细信息.
在这里,我有大量的lat long值,我将它循环到我的jsp中,并使用信息窗口创建多个标记.
现在问题是我需要在谷歌地图的信息窗口中显示特定纬度和经度的位置名称.
任何人都可以帮助我使用谷歌地图脚本或如何从我的Android手机本身的lat长值获取位置名称,以便我可以将其发布到我的网络服务器.
Dyn*_*ind 35
在这里我给了一个只是通过这个函数的纬度和经度,然后你得到了与这个纬度和经度相关的所有信息.
public void getAddress(double lat, double lng) {
Geocoder geocoder = new Geocoder(HomeActivity.mContext, Locale.getDefault());
try {
List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
Address obj = addresses.get(0);
String add = obj.getAddressLine(0);
add = add + "\n" + obj.getCountryName();
add = add + "\n" + obj.getCountryCode();
add = add + "\n" + obj.getAdminArea();
add = add + "\n" + obj.getPostalCode();
add = add + "\n" + obj.getSubAdminArea();
add = add + "\n" + obj.getLocality();
add = add + "\n" + obj.getSubThoroughfare();
Log.v("IGA", "Address" + add);
// Toast.makeText(this, "Address=>" + add,
// Toast.LENGTH_SHORT).show();
// TennisAppActivity.showDialog(add);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
Run Code Online (Sandbox Code Playgroud)
我希望你能回答你.
我对几个月前发布的问题有一个非常简单的答案....请检查一下......这对我有用..
Geocoder myLocation = new Geocoder(yourContext, Locale.getDefault());
List<Address> myList = myLocation.getFromLocation(Double.parseDouble(latitude),Double.parseDouble(longitude), 1);
Address address = (Address) myList.get(0);
String addressStr = "";
addressStr += address.getAddressLine(0) + ", ";
addressStr += address.getAddressLine(1) + ", ";
addressStr += address.getAddressLine(2);
Run Code Online (Sandbox Code Playgroud)
这是代码......
StringBuilder _homeAddress = null;
try{
_homeAddress = new StringBuilder();
Address address = null;
List<Address> addresses = _coder.getFromLocation(_lat,_lon,1);
for(int index=0; index<addresses.size(); ++index)
{
address = addresses.get(index);
_homeAddress.append("Name: " + address.getLocality() + "\n");
_homeAddress.append("Sub-Admin Ares: " + address.getSubAdminArea() + "\n");
_homeAddress.append("Admin Area: " + address.getAdminArea() + "\n");
_homeAddress.append("Country: " + address.getCountryName() + "\n");
_homeAddress.append("Country Code: " + address.getCountryCode() + "\n");
_homeAddress.append("Latitude: " + address.getLatitude() + "\n");
_homeAddress.append("Longitude: " + address.getLongitude() + "\n\n");
}
}
catch(Exception e){
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
34846 次 |
| 最近记录: |