将街道地址转换为坐标 Android

4

我正在尝试找到一种方法,在Android应用程序中使用Google地图将给定的街道地址转换为坐标。请问有什么建议或相关链接可以阅读吗?


2
你尝试过阅读 Google 地图 API 吗? - deb0rian
1个回答

1

试试这个

 Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
 String textToSearch = searchText.getText().toString();
 List<Address> fromLocationName = null;
 fromLocationName = geocoder.getFromLocationName(texToSearch,   1);
 if (fromLocationName != null && fromLocationName.size() > 0) {
    Address a = fromLocationName.get(0);
    GeoPoint point = new GeoPoint(
                         (int) (a.getLatitude() * _1E6), 
                         (int) (a.getLongitude() * _1E6));
 }

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接