I'm developing a location-aware application and I need a kind of "Around Me" function that shows the closest points of interest (POIs) to the user. What I'm trying to do is to show the POIs in a table view where there's written the name of the POI, the distance from the device location and I would like also to show an arrow that point to the direction to reach the POI as shown in the following picture.
I know the bearing (angle) between the user's location and the POI's location, the problem is when the user changes his heading and I need to update the bearing about the two locations. Does anyone has a suggestion about the formula? What I tried at the moment is to get the magnetic heading from the user location and subtract the initial bearing computed in order to do:
double relativeDirectionToCoordinate = degreesToRadians(magnHeadingDeg) - directionToCoordinate;
cell.imageView.transform = CGAffineTransformMakeRotation(relativeDirectionToCoordinate);
where magnHeadingDeg is the magnetic heading of the user location transfor开发者_开发问答med then in radians and directionToCoordinate is the initial bearing of the two locations.
This approach seems not correct, so please if you have some advice I would appreciate it.
Thank you
精彩评论