【发布时间】:2016-10-17 02:47:55
【问题描述】:
我在 Eclipse 中使用 Google 地图开发了一个适用于 Android 的应用程序。问题是指示我当前位置的蓝点总是与我正在驾驶的道路平行,在城市以外的道路上。但是,如果您在城市内,则该点已经在路的顶部。
我正在使用它在应用程序启动时获取我的位置:
locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
Location myLocation = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false));
然后我将蓝点添加到地图上:
googleMap.setMyLocationEnabled(true);
然后我开始监听位置变化:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, time, 1, this);
我的位置变更功能:
@Override
public void onLocationChanged(Location location) {
if (location != null) {
Lat1 = location.getLatitude();
Long1 = location.getLongitude();
if (Lat1 != Lat || Long1 != Long) {
Lat = location.getLatitude();
Long = location.getLongitude();
if (startNav == true) {
googleMap.animateCamera(CameraUpdateFactory
.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 17));
b = new LatLng(Lat, Long);
if (a != null) {
String urlTopass = makeURL(b.latitude, b.longitude, a.latitude, a.longitude);
new connectAsyncTask(urlTopass).execute();
}
}
}
}
}
我的问题是为什么蓝点看起来与街道平行,而不是在街道上方?
【问题讨论】:
标签: android eclipse google-maps