android使用百度地图获取自己所在的城市名
16lz
2021-01-25
在onLocationChanged方法里获得自己当前的坐标
然后方法里写 mSearch.reverseGeocode(new GeoPoint((int)(location.getLatitude()*1e6),(int)(location.getLongitude()*1e6)));
然后再通过代码实行这个方法功能
public class MySearchListener implements MKSearchListener {
public void onGetAddrResult(MKAddrInfo result, int error){
MKGeocoderAddressComponent kk=result.addressComponents;
String city=kk.city;
}
}
city就是你所在城市
然后方法里写 mSearch.reverseGeocode(new GeoPoint((int)(location.getLatitude()*1e6),(int)(location.getLongitude()*1e6)));
然后再通过代码实行这个方法功能
public class MySearchListener implements MKSearchListener {
public void onGetAddrResult(MKAddrInfo result, int error){
MKGeocoderAddressComponent kk=result.addressComponents;
String city=kk.city;
}
}
city就是你所在城市
更多相关文章
- android中访问 webView加载URL时的response数据
- Android之Fragment动态加载、Fragment与Activity传值通信
- [Android(安卓)Pro] ListView,GridView之LayoutAnimation特殊动
- SQLite的query方法,注意检查参数args中是否含null值
- Android(安卓)6.0关于权限的问题
- Android组件Activity中的View绘画和动画(Animation)是否会重画?
- Android面试题(25)-Bundle机制
- Android(安卓)SDK 中文 (56) —— ViewFlipper
- 使用otta bus进行android组件通信