4

I have the center of a circle and it's radius and I need to place variable amount of markers on the outline/stroke of the circle. The distance between this markers should kept same, so if I have 8 markers to put on the orbit, each of them has 45 degree space (360 / 8) and also it should not be hard-coded as the number of markers is variable.

I wanted to know what is the right way for calculating the Geo-coordinates of each marker?

here you can see an example, the outer marker should move on, however I can't calculate the proper LatLng values.

enter image description here


I finally came up with this formula:

var dg = 90;
var lat = Math.sin(dg * Math.PI / 180) * r + center_geo_lat;
var lng = Math.cos(dg * Math.PI / 180) * r + center_geo_lng;

If you look at snapshots you can see that markers at 0 and 180 degree has placed quite fine, but it seems there is something wrong with other markers. It's gonna works fine for me, because I don't need such a perfect accuracy, however I'm wondering what's cause the problem?

enter image description here

enter image description here

underdark
  • 84,148
  • 21
  • 231
  • 413
Mahdi
  • 306
  • 2
  • 11
  • 2
    Please see this Question and Answers for the info on the stretch in a North/South direction http://gis.stackexchange.com/questions/6822/why-is-the-straight-line-path-across-continent-so-curved – Mapperz Oct 26 '12 at 13:10
  • I merged your questions since the second one was following up on your first attempt at solving the question posed in the first one. – underdark Oct 26 '12 at 13:32
  • @Mahdi What is radius' unit in this question ... meters, kms, miles etc ? – Haris ur Rehman Nov 27 '17 at 19:14
  • @HarisurRehman Sorry I can't really remember. I guess that should be kilometres -- same as earth's radius unit, in this example, but I might be wrong. – Mahdi Nov 28 '17 at 21:02
  • No its not kilometres, just tested. https://i.imgur.com/dKdiNp4.png – Haris ur Rehman Nov 29 '17 at 03:58
  • @HarisurRehman Try it as meter then. I doubt if it's mile. – Mahdi Nov 29 '17 at 08:20
  • did you ever figure this out, i'm looking to try something similar? – Lee Smith Aug 16 '18 at 07:47
  • @LeeSmith Unfortunately I don't think there is any solution for that. The projection of the map is distorted/stretched, so placing a perfect circle -- or any of other shape for that matter, will be displayed distorted as well. We don't notice this distortion on the map itself, because the map itself doesn't have any regular shapes in it. – Mahdi Aug 16 '18 at 12:26

1 Answers1

3

I think this is all down to the projection you're using. Looks like your code is correct, but basically you can't assume that by travelling one unit longitudinally on a map will look the same as the same distance latitudinally.

This has a nice explanation of the differences in projections (see the bit under Tissot's indicatrix):

http://geokov.com/education/map-projection.aspx

pecoanddeco
  • 1,034
  • 1
  • 6
  • 12