开发者

android gps cover long area

i'm using gps and i add some over lay points in the map so i want when my current location is == the over lay 开发者_Python百科item remove the item ! the problem is the gps inaccuracy and i may be in place near the overlay item but not same longitude and lat. so i want to add area around the overlay item say a delta so the question is what the delta suppose to be for sure its cant be int or float what it should be to add it to my over lay item lang and latitude . Thank in advance


I'm not very experienced with GPS on Android, but it seems to me that you should be able to calculate the distance from your current position to the overlay item and check if it is less than some acceptable threshold. This just takes a little vector math:

int XSquared = Math.pow(myPosition.x - Item.x, 2);
int YSquared = Math.pow(myPosition.y - Item.y, 2);
double distance = Math.sqrt(XSquared + YSquared);

if(distance < threshold)
   removeItem(item);

Obviously this is not what the code will actually look like, but I hope it will give you some idea as to what you need to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜