Google지도에서 MyLocationOverlay
클래스를 구현하려고합니다. 그러나, 내 자신의 locationManager를 사용하려고 할 때 - 나는 오버레이를 acutally지도 위에 그리게 할 수 없다. 내가 뭔가 잘못하고 있는지 궁금해.내 위치 중첩 업데이트 시간 맞춤 설정
MyLocationOverlay 클래스의 super 메서드 (enbaleMyLocation)를 locationManager에서 너무 빨리 업데이트하고 배터리를 먹을 것이므로이 메서드를 호출하고 싶지 않습니다.
private class CenterOverlay extends MyLocationOverlay {
private Context mContext;
private LocationManager mLocManager;
public CenterOverlay(Context context, MapView mapView) {
super(context, mapView);
this.mContext = context;
}
@Override
public void onLocationChanged(Location location) {
super.onLocationChanged(location);
try {
doExternalCenterOverlayTask(location);
} catch (JSONException e) {
e.printStackTrace();
ErrorHandler.serviceException(mContext);
} catch (IOException e) {
e.printStackTrace();
ErrorHandler.IOException(mContext);
} catch (ServiceException e) {
e.printStackTrace();
ErrorHandler.serviceException(mContext);
}
}
@Override
public boolean enableMyLocation() {
mLocManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
mLocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 50, this);
mLocManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 25, this);
return mLocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|| mLocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
}
@Override
public void disableMyLocation() {
super.disableMyLocation();
mLocManager.removeUpdates(this);
}
@Override
public void onProviderDisabled(String provider) {
super.onProviderDisabled(provider);
ViewAdapter.createStandardAlertDialog(mContext,
"Your location provider has been disabled, please re-enable it.");
}
@Override
public void onProviderEnabled(String provider) {
super.onProviderEnabled(provider);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
super.onStatusChanged(provider, status, extras);
if (status == 0) {
ViewAdapter.showLongToast(mContext, "Location is not available at this time");
} else if (status == 1) {
//Trying to connect
} else if (status == 2) {
// Available
}
}
}
게시물을 보내 주셔서 감사합니다. 작동하지 않는 것 같습니다. "GeoPoint leftGeo = new GeoPoint ("저는 새로 만든 객체에서 enableMyLocation()이라는 새 CenterOverlay 객체를 만든 후 오버레이에 객체를 추가했습니다. mapView.getOverlays(). add (obj). 내가 잘못 했나요? 미리 감사드립니다! – Dr1Ku