Show current location of user on an offline static image (jpeg) - Android

独自空忆成欢 提交于 2019-12-10 00:12:57

问题


Background / Concept: I want to create an application that can help user searching for specific things. Let say nearby restaurants. Here I want to include an offline map covering 1 km area around that restaurant, (its easy i can take snap of google map).

Problem: is it possible to indicate current user position on that static image file? I have some idea that I note the Lat / Long of all four corners of that image, take user current position, do some calculation and show the current spot.. But I m not sure where to start and if there is already a good optimized solution.

If I can show current user direction (heading) it will be awesome!

MORE CONCISE QUESTION: I have a jpeg image (which is actually a street map) and I know lat / long of all four corners of image. How can i show current user location on that image?

P.S. The application is suppose to work without data connection, so I can't load google map etc


回答1:


Lets say that user position is uLat and uLon, and the map have top left corner tlLat and tlLon, and bottom right corner brLat and brLon. Finally, map size is x and y pixels.

userX = x*(uLon-tlLon)/(brLon-tlLon);
userY = y-y*(uLat-brLat)/(tlLat-brLat);

This is an aproximation that only works for small distances (1 km should be fine) as it's not taking into consideration the earth curvature.

I'm not sure that's legal to use google map screenshot without authorization.

good luck.



来源:https://stackoverflow.com/questions/12655639/show-current-location-of-user-on-an-offline-static-image-jpeg-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!