Given a latitude and longitude, Get the location name(给定经纬度,获取位置名称)
问题描述
我正在开发一个应用程序,其中我在我的 android 设备中获取纬度、经度并将它们发布到网络服务器.
I am developing an application wherein I get the latitude, longitude in my android device and post them to a web server.
在网络应用程序中,我借助谷歌地图显示位置详细信息.
and in a web application I show the location details with the help of google maps.
在这里,我收集了大量 lat long 值,我将其循环到我的 jsp 中并使用信息窗口创建多个标记.
Here I have huge collection of lat long values which i loop it in my jsp and create multiple markers with info windows.
现在的问题是我需要在谷歌地图的信息窗口中显示特定纬度和经度的位置名称.
Now the problem is that I need to show the location name of the particular latitude and longitude in the Info Window of google maps.
谁能帮助我使用 google maps 脚本,或者我如何从我的 android 手机本身的 lat long 值中获取位置名称,以便我可以将其发布到我的网络服务器.
Can anyone help me with the google maps script or how can i get the location name from the lat long values in my android phone itself, so that I can post that to my web server.
推荐答案
这里给我一个单,只要在这个函数中传入经纬度就可以得到这个经纬度相关的所有信息.
Here i am given a single just pass the latitude and longitude in this function then you got all the information related to this latitude and longitude.
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 + "
" + obj.getCountryName();
add = add + "
" + obj.getCountryCode();
add = add + "
" + obj.getAdminArea();
add = add + "
" + obj.getPostalCode();
add = add + "
" + obj.getSubAdminArea();
add = add + "
" + obj.getLocality();
add = add + "
" + 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();
}
}
这篇关于给定经纬度,获取位置名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:给定经纬度,获取位置名称


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01