I am developing google map app for android. Some positions are fixed in it. I am checking the bearing angle from my current position to marker How to check the Marker position, Weather it on left or right from my current location. Thanks in advance
Asked
Active
Viewed 174 times
0
-
Compare the longitudes from the marker and the current position. – Tim Biegeleisen Sep 27 '18 at 10:50
-
Thanks for quick response. But problem is that user can move either side, so how can we get "right or left" position of a custom marker with respect to updated position for moving user. – Abdul Hannan Sep 27 '18 at 10:56
-
Can you not obtain the position of the current location? As for the markers, they are fixed anyway. – Tim Biegeleisen Sep 27 '18 at 10:58
-
Yes I can get, but how to find the current user movement direction, because if user is moving in one side, the marker will be in left side, while if moving on right side, the marker will be on right side... – Abdul Hannan Sep 27 '18 at 11:04
-
You might want to post some code which illustrates your problem. I don't see why you are even asking a question. – Tim Biegeleisen Sep 27 '18 at 11:05
-
double lat2 = 31.460549999999994; double lng2 = 74.3240433; double dLon = (lng2-location.getLongitude()); double y = Math.sin(dLon) * Math.cos(lat2); double x = Math.cos(location.getLatitude())*Math.sin(lat2) - Math.sin(location.getLatitude())*Math.cos(lat2)*Math.cos(dLon); double brng = Math.toDegrees((Math.atan2(y, x))); brng = (360 - ((brng + 360) % 360)); – Abdul Hannan Sep 27 '18 at 11:27
-
problem is that if user only change its direction (not position), then how can we find the left or right position of marker for new direction. – Abdul Hannan Sep 27 '18 at 11:38
-
https://stackoverflow.com/a/4316717/2711811 - you'll need your bearing and then use Location to get "bearing to" marker (referenced from north), compensate for your bearing and the left-right is just the 180 cutoff (if 0-360) or sign (if -180 to 180). – Sep 27 '18 at 16:51