Search in sources :

Example 1 with AnimateDraggingMapThread

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);
        }
    }
}
Also used : OsmAndLocationProvider(net.osmand.plus.OsmAndLocationProvider) AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread) Location(net.osmand.Location)

Example 2 with AnimateDraggingMapThread

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);
}
Also used : AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread)

Example 3 with AnimateDraggingMapThread

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);
    }
}
Also used : LatLon(net.osmand.data.LatLon) AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread) MapMarker(net.osmand.plus.MapMarkersHelper.MapMarker)

Example 4 with AnimateDraggingMapThread

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);
}
Also used : AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread)

Example 5 with AnimateDraggingMapThread

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;
}
Also used : TextInfoWidget(net.osmand.plus.views.mapwidgets.TextInfoWidget) LatLon(net.osmand.data.LatLon) AnimateDraggingMapThread(net.osmand.plus.views.AnimateDraggingMapThread) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) View(android.view.View) TextView(android.widget.TextView) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Aggregations

AnimateDraggingMapThread (net.osmand.plus.views.AnimateDraggingMapThread)7 LatLon (net.osmand.data.LatLon)4 View (android.view.View)1 TextView (android.widget.TextView)1 Location (net.osmand.Location)1 PointDescription (net.osmand.data.PointDescription)1 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)1 OsmAndLocationProvider (net.osmand.plus.OsmAndLocationProvider)1 DrawSettings (net.osmand.plus.views.OsmandMapLayer.DrawSettings)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1 TextInfoWidget (net.osmand.plus.views.mapwidgets.TextInfoWidget)1