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();
}
}
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;
}
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));
}
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();
}
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();
}
}
Aggregations