Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top