【发布时间】:2013-08-25 21:08:59
【问题描述】:
我想获取当前坐标,我下一个试试
GoogleMap gm=getMap();
gm.setMyLocationEnabled(true);
Location location=getMap().getMyLocation();
但是 getMap() 返回 null, 我试试:
Criteria criteria = new Criteria();
String provider = service.getBestProvider(criteria, false);
Location location = service.getLastKnownLocation(provider);
if (location.getLatitude()!=0){
LatLng userLocation = new LatLng(location.getLatitude(), location.getLongitude());
但这项工作在 Android 2.3 中,但在 4.2 中。它返回空值。
【问题讨论】:
标签: android google-maps-android-api-2 android-location