Reputation: 302
I wanted to add the marker on touched location on Here Map. Also, i wanted to show the latitude and longitude where i touched the location. I am successful in showing the marker But i cannot able to show the latitude and longitude in toast message.
I have implemented my own gesture listener as explained in the doc:
public class MyOnGestureListener implements MapGesture.OnGestureListener
In this there is an overridden method 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.
Upvotes: 4
Views: 2294
Reputation: 1
With pixelToGeo(android.graphics.PointF point)
Geocoordinate geototap = map.pixelToGeo(pointf);
Double lat = geototap.getLatitude();
Double lng = geototap.getLongitude();
Upvotes: 0
Reputation: 1423
@AndrewJC is right. But for beginner, I will explain a bit. Here SDK has following implementation in their basic positioning section
PositioningManager.OnPositionChangedListener
which provides an interface, onPositionUpdated
. From this you can get GeoPosition
. Use this GeoPosition
to get latitude and longitude.
double latitude = geoposition.getCoordinate().getLatitude();
double longitude = geoposition.getCoordinate().getLongitude();
Upvotes: 0
Reputation: 1478
You can use Map#pixelToGeo(PointF point)
API to get the GeoCoordinate
from the PointF
. Then you can obtain the latitude and longitude values from the GeoCoordinate
.
Upvotes: 4