How to get latitude and longitude using the Android SDK card here?

I wanted to add a marker to an indirect location on the map. In addition, I wanted to show latitude and longitude when I touched the place. I will be able to show the marker. But I can’t show the latitude and longitude in the toast message.

I executed my own gesture listener as described in the document:    public class MyOnGestureListener implements MapGesture.OnGestureListener This has an overridden method that I used:

@Override
public boolean onTapEvent(PointF p) {
    // Toast.makeText(context, " Show latitude and langitude on touched location: " , Toast.LENGTH_SHORT ).show();
    return true;
}

In this I wanted to show latitude and longitude.

+4
source share
2 answers

You can use the API Map#pixelToGeo(PointF point)to get GeoCoordinatefrom PointF. Then you can get the latitude and longitude values ​​from GeoCoordinate.

API- pixelToGeo

+4

@AndrewJC . . SDK

PositioningManager.OnPositionChangedListener

onPositionUpdated. GeoPosition. GeoPosition .

double latitude = geoposition.getCoordinate().getLatitude();
double longitude = geoposition.getCoordinate().getLongitude();
0

Source: https://habr.com/ru/post/1681733/


All Articles