如何将GPS坐标转换为地址?

发布于 2024-12-22 12:50:42 字数 438 浏览 2 评论 0原文

可能的重复:
使用 Google 进行反向地理编码地图 API 和 PHP 使用经纬度坐标获取最近位置

如何在 Android 或 Php 上将 GPS 坐标(纬度和经度)转换为地址?

我的程序应该从给定的坐标获取地址。例如:

坐标:41.011576, 28.984852 -->地址 : Cankurtaran Mh., Kennedy Cd, Istanbul, Türkiye

我希望你能帮助我..

Possible Duplicate:
Reverse Geocoding With Google Map API And PHP To Get Nearest Location Using Lat,Long coordinates

How to convert gps coordinates ( latitude&longitude ) to address on Android or Php ?

My program should get address from given coordinates. For example :

Coordinates : 41.011576, 28.984852 --> Address : Cankurtaran Mh., Kennedy Cd, Istanbul, Türkiye

I hope, you can help me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伤痕我心 2024-12-29 12:50:42

Geocoder 类可以为 Android 执行您想要的操作。您可以使用 getFromLocation 您可以这样做:

    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    Address adress;
    String result = null;
    List<Address> list = geocoder.getFromLocation(latitude, longitude, 1);
    address = list.get(0);
    result = address.getAddressLine(0) + ", " + address.getLocality();
    //Now do what you want with result - this is the address.

您可能需要进行修改,例如如果您想要多个位置,则使用 getFromLocation 中的 1,或者使用 < code>address.getAddressLine 您可能想要获取多行。

您需要将其放在 try {} 块中并在工作线程中执行。

The Geocoder class can do what you want for Android. You would use getFromLocation You would do it as so:

    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
    Address adress;
    String result = null;
    List<Address> list = geocoder.getFromLocation(latitude, longitude, 1);
    address = list.get(0);
    result = address.getAddressLine(0) + ", " + address.getLocality();
    //Now do what you want with result - this is the address.

You may want to make modifications, such as the 1 in getFromLocation if you want more than one location, or with the address.getAddressLine you may want to get more than one line.

You will want to put it within a try {} block and do it in a worker thread.

唔猫 2024-12-29 12:50:42

Google 反向地理编码是您的朋友:http://code.google.com/apis/maps /文档/地理编码/

Google reverse geocoding is your friend: http://code.google.com/apis/maps/documentation/geocoding/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文