android - Detect Other User Location -
i want build android app detect other user position in real time (like uber app when driver went pickup customer).
[capture of uber app - pick customer]
i don't know right way build it, tried build trick.
[store , select user location]
this trick success. but...the problem are..
- with trick, there no information estimated time arrival.
- if wanna force estimate time arrival info, have send direction request api google maps, , make limit request api running out faster.
big appreciates help, links or examples.
thank you.
maulana
for suggestion introduce server. if admin need location of particular user(use id identify), admin app inform server (by api call). server push particular device (hosting id ) update periodically device location. user app notification(push best way here) , start updating server current co-ordinates(again api call) , whenever server receive updated location inform admin(via push/long pulling/tcp socket).
or
you can use device device communication, admin must have map of userid vs. gcm push id. if admin want track of user push notification particular device (via push). whenever of user device such notification start pushing current co-ordinates periodically.
if need distance , time mapping, better find via google api first. let suppose google apis response says distance 2km(apidistance) , take 8 min(apitime) move carlat, carlang current position(let userlat, userlang). every location update use simple distance mapping algo find distance remains :
private double distance(double carlat, double carlang, double userlat, double userlang) { double theta = carlang - userlang; double dist = math.sin(deg2rad(carlat)) * math.sin(deg2rad(userlat)) + math.cos(deg2rad(carlat)) * math.cos(deg2rad(userlat)) * math.cos(deg2rad(theta)); dist = math.acos(dist); dist = rad2deg(dist); dist = dist * 60 * 1.1515; return (dist); } private double deg2rad(double deg) { return (deg * math.pi / 180.0); } private double rad2deg(double rad) { return (rad * 180.0 / math.pi); }
now have apidistance , apitime(by last google api call) , updateddistance, can find out updatedtime (that approximate). correction can make google api call after standard time(might 1 min.) improve accuracy.
hope you, let me know if need further assistance :)
Comments
Post a Comment