Skip to content

Commit

Permalink
Save map position after it is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Feb 3, 2024
1 parent 122fd51 commit a764c71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/src/main/java/mobi/maptrek/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,12 @@ public void onChildViewRemoved(View parent, View child) {
int strokeColor = resources.getColor(R.color.colorBackground, theme);
DefaultMapScaleBar mapScaleBar = new DefaultMapScaleBar(mMap, MapTrek.density * .75f, paintColor, strokeColor);
mMapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
mCrosshairLayer = new CrosshairLayer(mMap, MapTrek.density, paintColor);
mCrosshairLayer = new CrosshairLayer(mMap, MapTrek.density, paintColor, new Runnable() {
@Override
public void run() {
Configuration.setPosition(mMap.getMapPosition());
}
});
mLocationOverlay = new LocationOverlay(mMap, MapTrek.density);
layers.add(mMapScaleBarLayer, MAP_OVERLAYS);
layers.add(mCrosshairLayer, MAP_OVERLAYS);
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/mobi/maptrek/layers/CrosshairLayer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 Andrey Novikov
* Copyright 2024 Andrey Novikov
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
Expand Down Expand Up @@ -33,12 +33,14 @@
import static org.oscim.backend.GLAdapter.gl;

public class CrosshairLayer extends Layer implements Map.UpdateListener {
private int mColor;
private final Runnable mOnHide;
private final int mColor;

public CrosshairLayer(Map map, float scale, int color) {
public CrosshairLayer(Map map, float scale, int color, Runnable onHide) {
super(map);
mColor = color;
mRenderer = new CrosshairRenderer(scale, color);
mOnHide = onHide;
}

@Override
Expand Down Expand Up @@ -174,6 +176,7 @@ public void render(GLViewport v) {
float alpha = 1f - animPhase();
if (alpha > mAlpha || alpha < 0.01f) {
mAlpha = 0f;
mMap.post(mOnHide);
animate(false);
} else {
mAlpha = alpha;
Expand Down

0 comments on commit a764c71

Please sign in to comment.