use of net.osmand.plus.views.AnimateDraggingMapThread in project Osmand by osmandapp.
the class MapViewTrackingUtilities method backToLocationImpl.
public void backToLocationImpl(int zoom) {
if (mapView != null) {
OsmAndLocationProvider locationProvider = app.getLocationProvider();
if (!isMapLinkedToLocation()) {
setMapLinkedToLocation(true);
net.osmand.Location lastKnownLocation = locationProvider.getLastKnownLocation();
if (lastKnownLocation != null) {
AnimateDraggingMapThread thread = mapView.getAnimatedDraggingThread();
int fZoom = mapView.getZoom() < zoom ? zoom : mapView.getZoom();
movingToMyLocation = true;
thread.startMoving(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), fZoom, false, new Runnable() {
@Override
public void run() {
movingToMyLocation = false;
}
});
}
mapView.refreshMap();
}
if (locationProvider.getLastKnownLocation() == null) {
app.showToastMessage(R.string.unknown_location);
}
}
}
use of net.osmand.plus.views.AnimateDraggingMapThread in project Osmand by osmandapp.
the class MapActivity method onPause.
@Override
protected void onPause() {
mapView.setOnDrawMapListener(null);
cancelSplashScreenTimer();
app.getMapMarkersHelper().removeListener(this);
app.getRoutingHelper().removeListener(this);
app.getDownloadThread().resetUiActivity(this);
if (atlasMapRendererView != null) {
atlasMapRendererView.handleOnPause();
}
super.onPause();
app.getLocationProvider().pauseAllUpdates();
app.getDaynightHelper().stopSensorIfNeeded();
settings.APPLICATION_MODE.removeListener(applicationModeListener);
settings.setLastKnownMapLocation((float) mapView.getLatitude(), (float) mapView.getLongitude());
AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread();
if (animatedThread.isAnimating() && animatedThread.getTargetIntZoom() != 0 && !mapViewTrackingUtilities.isMapLinkedToLocation()) {
settings.setMapLocationToShow(animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(), animatedThread.getTargetIntZoom());
}
settings.setLastKnownMapZoom(mapView.getZoom());
settings.MAP_ACTIVITY_ENABLED.set(false);
getMyApplication().getAppCustomization().pauseActivity(MapActivity.class);
app.getResourceManager().interruptRendering();
OsmandPlugin.onMapActivityPause(this);
}
use of net.osmand.plus.views.AnimateDraggingMapThread in project Osmand by osmandapp.
the class MapMarkersWidgetsFactory method showMarkerOnMap.
private void showMarkerOnMap(int index) {
if (helper.getMapMarkers().size() > index) {
MapMarker marker = helper.getMapMarkers().get(index);
AnimateDraggingMapThread thread = map.getMapView().getAnimatedDraggingThread();
LatLon pointToNavigate = marker.point;
if (pointToNavigate != null) {
int fZoom = map.getMapView().getZoom() < 15 ? 15 : map.getMapView().getZoom();
thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
}
// MapMarkerDialogHelper.showMarkerOnMap(map, marker);
}
}
use of net.osmand.plus.views.AnimateDraggingMapThread in project Osmand by osmandapp.
the class MapContextMenuFragment method onDestroyView.
@Override
public void onDestroyView() {
super.onDestroyView();
if (!menu.isActive()) {
if (mapCenter != null) {
if (mapZoom == 0) {
mapZoom = map.getZoom();
}
// map.setLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
// map.setIntZoom(mapZoom);
AnimateDraggingMapThread thread = map.getAnimatedDraggingThread();
thread.startMoving(mapCenter.getLatitude(), mapCenter.getLongitude(), mapZoom, true);
}
}
menu.setMapCenter(null);
menu.setMapZoom(0);
}
use of net.osmand.plus.views.AnimateDraggingMapThread in project Osmand by osmandapp.
the class ParkingPositionPlugin method createParkingPlaceInfoControl.
/**
* @return the control to be added on a MapInfoLayer
* that shows a distance between
* the current position on the map
* and the location of the parked car
*/
private TextInfoWidget createParkingPlaceInfoControl(final MapActivity map) {
TextInfoWidget parkingPlaceControl = new TextInfoWidget(map) {
private float[] calculations = new float[1];
private int cachedMeters = 0;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
LatLon parkingPoint = parkingLayer.getParkingPoint();
if (parkingPoint != null && !map.getRoutingHelper().isFollowingMode()) {
OsmandMapTileView view = map.getMapView();
int d = 0;
if (d == 0) {
net.osmand.Location.distanceBetween(view.getLatitude(), view.getLongitude(), parkingPoint.getLatitude(), parkingPoint.getLongitude(), calculations);
d = (int) calculations[0];
}
if (distChanged(cachedMeters, d)) {
cachedMeters = d;
if (cachedMeters <= 20) {
cachedMeters = 0;
setText(null, null);
} else {
String ds = OsmAndFormatter.getFormattedDistance(cachedMeters, map.getMyApplication());
int ls = ds.lastIndexOf(' ');
if (ls == -1) {
setText(ds, null);
} else {
setText(ds.substring(0, ls), ds.substring(ls + 1));
}
}
return true;
}
} else if (cachedMeters != 0) {
cachedMeters = 0;
setText(null, null);
return true;
}
return false;
}
/**
* Utility method.
* @param oldDist
* @param dist
* @return
*/
private boolean distChanged(int oldDist, int dist) {
if (oldDist != 0 && Math.abs(oldDist - dist) < 30) {
return false;
}
return true;
}
};
parkingPlaceControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OsmandMapTileView view = map.getMapView();
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
LatLon parkingPoint = parkingPosition;
if (parkingPoint != null) {
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
thread.startMoving(parkingPoint.getLatitude(), parkingPoint.getLongitude(), fZoom, true);
}
}
});
parkingPlaceControl.setText(null, null);
parkingPlaceControl.setIcons(R.drawable.widget_parking_day, R.drawable.widget_parking_night);
return parkingPlaceControl;
}
Aggregations