我想制作一个程序来计算一些位置到我当前位置的距离,但我的googleMap.getMyLocation();没有正常工作。googleMap.getMyLocation();无法获取当前位置
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setCompassEnabled(false);
mylocation = googleMap.getMyLocation();
direction = new GMapV2Direction();
LatLng from, to;
from = new LatLng(-7.26071409, 112.80674726);
for(int i=0; i<lat.length; i++){
to = new LatLng(lat[i], lon[i]);
doc = direksi.getDocument(from, to, GMapV2Direction.MODE_DRIVING);
distance[i] = (double)direction.getDistanceValue(doc)/1000;
}
我保存了lat []和lon []中某些地方的经度和纬度。 LatLng'from'是mylocation,'to'是我的目的地。 当我改变
from = new LatLng(-7.26071409, 112.80674726);
to
from = new LatLng(mylocation.getLatitude(), mylocation.getLongitude());
我想要做的计算,而无需打开谷歌地图的问题出现。当我触摸地图按钮作为弹出窗口时,谷歌地图将出现。因此计算会发生,而无需打开GoogleMap的
请帮我
getMyLocation(),[此方法已弃用](https://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.html)。改用LocationClient。 – AlexDG
你在使用google map v2吗? –
@Alex我不知道如何使用LocationClient。你能详细说明吗? – user3506223