1

I'm trying to create a view that present a bunch of coordinates without using a map.
The user's coordinates should be at the center of the screen(in the middle of the circle),
and the rest of the coordinates will be layout relative to one another according to their real latitude and longitude.

Something like this:

enter image description here

I understood that I can't do this with MKMapKit because it will be a violation of Google license, so I need a way to place and manage the coordinates myself.

What is best practice to do something like this? how should I convert the coordinates to a screen points?

Eyal
  • 10,777
  • 18
  • 78
  • 130

1 Answers1

1

I'd go about it as follows:

1) I'd start by normalizing at the user's current location (translate it to 0,0 then apply the same translation to the rest of the coordinates).

2) Once you've done that, use a distance function to find out which coordinate in your list is furthest away from your current location.

3) Use the furthest away coordinate to determine the scale of your view.

4) Calculate the X & Y screen coordinates of all your locations based on the scale you come up with in #3

Sam
  • 1,504
  • 2
  • 13
  • 19
  • Be careful what you think of as "the same translation'. Any movement towards the equator while staying at the same longitude will make the horizontal distance greater. One degree of longitude at the equator is ~111km but at 50°N one longitudinal degree is ~78km. So just shifting all points by the same number of degrees is going to change the distances between them. Even if the points are close to each other you'll be distorting your world horizontally. – Craig Aug 20 '12 at 01:07
  • If they are really close, like all in the same city, you could use this to find the bearing http://stackoverflow.com/questions/3809337/calculating-bearing-between-two-cllocationcoordinate2ds and CLLocation's function to find the distance, then it is just trigonometry to plot the points from the center of the view. – Craig Aug 20 '12 at 01:10