Search code examples
androidpositionmappinghere-api

How to calculate Latitude and Longitude of a point by distance and direction from another point


I'm looking to calculate the latitude and longitude of where to place a marker that is a specific distance and direction from a known position's latitude and longitude. This is for an Android app (in Java) using the HERE mapping API.


Solution

  • Our Android Mobile SDK (Java) currently supports calculating distance between two geocoordinates (lat, lon) via the distanceTo method of the Geocoordinate class.

    https://developer.here.com/documentation/android-premium/api_reference_java/index.html

    The method you are requesting is currently not provided. However, our JavaScript SDK provides a walk method of the H.geo.Point class. This method returns the destination point, based on the given distance and bearing relative to the current point.

    https://developer.here.com/documentation/maps/topics_api/h-geo-point.html#h-geo-point__walk

    The algorithm is based on the Haversine formula and so you can also use the formula to calculate the target point yourself.