【问题标题】:Use overlay to show lists of location in mapView使用叠加层在 mapView 中显示位置列表
【发布时间】:2011-11-01 15:01:26
【问题描述】:

我有一个地址列表,但是我没有这些地址的实际经度和纬度。
将地址转换为长的任何方法。和纬度。 ,然后存入mysql数据库
然后,当我转到地图视图时,它得到了长列表。 & 纬度在 mysql 中并在 mapview 中显示
我是android新手所以请帮我解决^^

【问题讨论】:

    标签: php android mysql google-maps


    【解决方案1】:

    您需要正向地理编码 前向地理编码(或只是地理编码)确定给定位置的地图坐标。

    这里是例子

    //这是获取地理位置的sn-p

    List<Address> result = geocoder.getFromLocationName(aStreetAddress, maxResults);
    Geocoder fwdGeocoder = new Geocoder(this, Locale.US);
    String streetAddress = “160 Riverside Drive, New York, New York”;
    

    .................................................. ……………………………………………………………………………… 如何做到这一点...

    List<Address> locations = null;
     try {
    locations = fwdGeocoder.getFromLocationName(streetAddress, 10);
    } catch (IOException e) {}
    

    其中 10 是最大结果,因为我可以有多个同名位置。 这将简单地返回 lat 和 lang(geo points)

    获取经纬度列表后,将它们添加到数据库中。

    【讨论】:

    • 另外在循环中添加上面的代码,它将用一个 for 循环遍历列表中的每个地址:)
    • 但实际上只需要将地址转换为Gpoint一次,所以你推荐使用这个^^?
    • 是的,但如果您想要更多位置点,请遍历地址。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    相关资源
    最近更新 更多