Search in sources :

Example 1 with LngLat

use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.

the class MapFragment method showLocation.

private void showLocation() {
    if (accuracyMarker != null && locationMarker != null && directionMarker != null && lastLocation != null) {
        LngLat pos = new LngLat(lastLocation.getLongitude(), lastLocation.getLatitude());
        locationMarker.setVisible(true);
        accuracyMarker.setVisible(true);
        directionMarker.setVisible(isShowingDirection);
        locationMarker.setPointEased(pos, 1000, MapController.EaseType.CUBIC);
        accuracyMarker.setPointEased(pos, 1000, MapController.EaseType.CUBIC);
        directionMarker.setPointEased(pos, 1000, MapController.EaseType.CUBIC);
        updateAccuracy();
    }
}
Also used : LngLat(com.mapzen.tangram.LngLat)

Example 2 with LngLat

use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.

the class MapFragment method onDoubleTap.

/* -------------------------------- Touch responders --------------------------------------- */
@Override
public boolean onDoubleTap(float x, float y) {
    if (requestUnglueViewFromPosition()) {
        LngLat zoomTo = controller.screenPositionToLngLat(new PointF(x, y));
        controller.setPositionEased(zoomTo, 500);
    }
    controller.setZoomEased(controller.getZoom() + 1.5f, 500);
    updateView();
    return true;
}
Also used : LngLat(com.mapzen.tangram.LngLat) PointF(android.graphics.PointF)

Example 3 with LngLat

use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.

the class MapFragment method restoreMapState.

private void restoreMapState() {
    SharedPreferences prefs = getActivity().getPreferences(Activity.MODE_PRIVATE);
    if (prefs.contains(PREF_ROTATION))
        controller.setRotation(prefs.getFloat(PREF_ROTATION, 0));
    if (prefs.contains(PREF_TILT))
        controller.setTilt(prefs.getFloat(PREF_TILT, 0));
    if (prefs.contains(PREF_ZOOM))
        controller.setZoom(prefs.getFloat(PREF_ZOOM, 0));
    if (prefs.contains(PREF_LAT) && prefs.contains(PREF_LON)) {
        LngLat pos = new LngLat(Double.longBitsToDouble(prefs.getLong(PREF_LON, 0)), Double.longBitsToDouble(prefs.getLong(PREF_LAT, 0)));
        controller.setPosition(pos);
    }
    setIsFollowingPosition(prefs.getBoolean(PREF_FOLLOWING, true));
    setCompassMode(prefs.getBoolean(PREF_COMPASS_MODE, false));
}
Also used : LngLat(com.mapzen.tangram.LngLat) SharedPreferences(android.content.SharedPreferences)

Example 4 with LngLat

use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.

the class MapFragment method saveMapState.

private void saveMapState() {
    if (controller == null)
        return;
    SharedPreferences.Editor editor = getActivity().getPreferences(Activity.MODE_PRIVATE).edit();
    editor.putFloat(PREF_ROTATION, controller.getRotation());
    editor.putFloat(PREF_TILT, controller.getTilt());
    editor.putFloat(PREF_ZOOM, controller.getZoom());
    LngLat pos = controller.getPosition();
    editor.putLong(PREF_LAT, Double.doubleToRawLongBits(pos.latitude));
    editor.putLong(PREF_LON, Double.doubleToRawLongBits(pos.longitude));
    editor.putBoolean(PREF_FOLLOWING, isFollowingPosition);
    editor.putBoolean(PREF_COMPASS_MODE, isCompassMode);
    editor.apply();
}
Also used : LngLat(com.mapzen.tangram.LngLat) SharedPreferences(android.content.SharedPreferences)

Example 5 with LngLat

use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.

the class MapFragment method followPosition.

protected void followPosition() {
    if (shouldCenterCurrentPosition()) {
        controller.setPositionEased(new LngLat(lastLocation.getLongitude(), lastLocation.getLatitude()), 500);
        if (!zoomedYet) {
            zoomedYet = true;
            controller.setZoomEased(19, 500);
        }
        updateView();
    }
}
Also used : LngLat(com.mapzen.tangram.LngLat)

Aggregations

LngLat (com.mapzen.tangram.LngLat)11 SharedPreferences (android.content.SharedPreferences)2 Point (android.graphics.Point)2 PointF (android.graphics.PointF)2 LatLon (de.westnordost.osmapi.map.data.LatLon)2 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Rect (android.graphics.Rect)1 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)1