use*_*706 0 android google-maps android-fragments
是否有可能具有搜索功能 - 例如在操作栏中 - 可以搜索谷歌地图片段中的街道名称?我正在开发一个应用程序,这将是非常有用的.如果应用程序可以导航到该位置.
是的,你可以在Geocoder课程的帮助下.AFAIK内置的Android Geocoder依赖于ESRI的地理编码Web服务.
Geocoder geocoder = new Geocoder(this);
List<Address> addresses = null;
try {
// Find a maximum of 3 locations with the name Kyoto
addresses = geocoder.getFromLocationName("Kyoto", 3);
} catch (IOException e) {
e.printStackTrace();
}
if (addresses != null) {
for (Address loc : addresses) {
MarkerOptions opts = new MarkerOptions()
.position(new LatLng(loc.getLatitude(), loc.getLongitude()))
.title(loc.getAddressLine(0));
mMap.addMarker(opts);
}
}
Run Code Online (Sandbox Code Playgroud)
笔记:
编辑:
基于esri的arcgis开发者网站,Geocoder依赖于ESRI的Web服务.我也对此感到惊讶,但由于Google的Geolocation API有局限性,而且Android的Geocoder位置功能没有(我不知道)限制,因此它有点意义.
| 归档时间: |
|
| 查看次数: |
1718 次 |
| 最近记录: |