I'm stuck into some kind of geolocation limbo using a custom map with iPhone. The problem is: I have an UIScrollView
and an UIImageView
with a image of a custom map for a fair, with all stand locations and so on.
My biggest problem is that I intend to use geolocation in order to locate the person inside that map. The problem begins when I try to get the pixel location of a given latitude and longitude. I have several ground control points as reference and even managed to calculate the an angle between my reference spot and the current location. The problem is that I can't correlate the distance in pixels with a distance calculated with the geolocation coordinates.
I am trying to relate them as follows:
Calculating the distance in pixels of a known point in my map. Calculating the distance using vector distance calculation for two reference points. Equaling the two above to find the actual distance from the reference.
But I am having no success at all...
Using the law of cosines, I can find the angle that will give my projections of X and Y but I can't find a scale to multiply correctly. I guess is because latitude and longitude are given in degrees and are non-linear, but I have such a small spot that I can aproximate it as linear spot.
I can't use an overlay image in MKMapKit because I have to use the map horizontally and in google maps, the same place is rotate several degrees to the left.
UPDATE:
Following this site: http://www.movable-type.co.uk/scripts/latlong.html, i could calculate the distance using the Haversine formula, but as orientation bellow, i found out that I was calculating the angle in a wrong way. I will have to find another way to calculate the angle.
See Question&Answers more detail:os