-2

I am plotting route between two location. i want to show start location at top side on map always and end location at bottom side. How to achieve this?

  • What have you tried so far? Make an attempt and come back here with specific questions about your stumbling points. "Write my code for me" is not an acceptable question. – Stonz2 Nov 24 '15 at 20:35

1 Answers1

1

Here is how I would approach the problem.

  1. Calculate the heading from your starting point.
    • Ex 1: Point A -> Point B => Heading of 240°
    • Ex 2: Point A -> Point B => Heading of 79°
  2. Using this heading, subtract 180°.
    • Ex 1: 240° - 180° => 60°
    • Ex 2: 79° - 180 => 259°
  3. Orient your map extent facing value you found in step 2.
    • Ex 1: Map is facing 60° instead of north
    • Ex 2: Map is facing 259° instead of north
  4. Re-fit your map extent to comfortably fit the points. Many mapping APIs have things that can do this for you.

This should have the starting point at the top of your map, and the end point at the bottom.

Also, remember in your calculations with degrees that values wrap back around to 0° at 360°.

Community
  • 1
  • 1
72A12F4E
  • 1,744
  • 1
  • 14
  • 28
  • How will i get heading 240 degree value for A and 79 degree for B point? I will plot route anywhere on map, not from user's current location. please help me if you have any solution. – Shankar Phadatare Nov 24 '15 at 21:22
  • The 240 and 79 values are separate examples. You will calculate the heading between your start (A) and end (B) points using calculations like in the following links: http://stackoverflow.com/questions/26998029/calculating-bearing-between-two-cllocation-points-in-swift or https://developers.google.com/maps/documentation/ios-sdk/reference/group___geometry_utils.html#ga960b42774b5eaecfd25a9e2349f2c0d3 – 72A12F4E Nov 24 '15 at 21:24