Merge pull request #9661 from osmandapp/Fix_my_location
Fix #9408 Don't show "Whats here" menu
This commit is contained in:
commit
3b37d0b272
2 changed files with 24 additions and 13 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue