Merge pull request #9661 from osmandapp/Fix_my_location

Fix #9408 Don't show "Whats here" menu
This commit is contained in:
Vitaliy 2020-08-19 14:58:06 +03:00 committed by GitHub
commit 3b37d0b272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 13 deletions

View file

@ -574,11 +574,21 @@ public class ContextMenuLayer extends OsmandMapLayer {
applyingMarkerLatLon = null;
}
public boolean showContextMenuForMyLocation() {
PointLocationLayer provider = view.getLayerByClass(PointLocationLayer.class);
if (provider != null) {
LatLon ll = provider.getObjectLocation(null);
if (ll != null) {
PointDescription pointDescription = provider.getObjectName(null);
return showContextMenu(ll, pointDescription, ll, provider);
}
}
return false;
}
public boolean showContextMenu(double latitude, double longitude, boolean showUnknownLocation) {
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
float x = cp.getPixXFromLatLon(latitude, longitude);
float y = cp.getPixYFromLatLon(latitude, longitude);
return showContextMenu(new PointF(x, y), activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
return showContextMenu(getPointFromLatLon(latitude, longitude),
activity.getMapView().getCurrentRotatedTileBox(), showUnknownLocation);
}
public boolean showContextMenu(@NonNull LatLon latLon,
@ -803,6 +813,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
return false;
}
private PointF getPointFromLatLon(double latitude, double longitude) {
RotatedTileBox cp = activity.getMapView().getCurrentRotatedTileBox();
float x = cp.getPixXFromLatLon(latitude, longitude);
float y = cp.getPixYFromLatLon(latitude, longitude);
return new PointF(x, y);
}
private List<String> getValues(@Nullable QStringStringHash set) {
List<String> res = new ArrayList<>();
if (set != null) {

View file

@ -439,15 +439,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
private void showContextMenuForMyLocation() {
OsmAndLocationProvider lp = app.getLocationProvider();
Location lastKnownLocation = lp.getLastKnownLocation();
Location lastStaleKnownLocation = lp.getLastStaleKnownLocation();
Location location = lastKnownLocation != null ? lastKnownLocation : lastStaleKnownLocation;
if (location != null) {
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
if (cml != null) {
cml.showContextMenu(location.getLatitude(), location.getLongitude(), true);
}
ContextMenuLayer cml = mapActivity.getMapView().getLayerByClass(ContextMenuLayer.class);
if (cml != null) {
cml.showContextMenuForMyLocation();
}
}