我想制作一个程序来计算一些地方到我当前位置之间的距离,但是我的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;
}
Run Code Online (Sandbox Code Playgroud)
我保存了lat []和lon []中某些地方的纬度和经度.LatLng'from'是mylocation,'to'是我的目的地.我改变时出现问题
from = new LatLng(-7.26071409, 112.80674726);
to
from = new LatLng(mylocation.getLatitude(), mylocation.getLongitude());
Run Code Online (Sandbox Code Playgroud)
我想在不打开googlemaps的情况下进行计算.当我将地图按钮作为弹出窗口触摸时,将显示谷歌地图.所以计算将在不打开googlemap的情况下进行
请帮我