# Create a circle polygon in GMaps.Net?

I found this function and converted it to VB.Net. It draws an oval rather than a circle. What do I need to do to fix the calculations?

``````Dim seg As Double = Math.PI * 2 / segments
For i As Integer = 0 To segments - 1
Dim theta As Double = seg * i
Dim a As Double = _pll.Lat + Math.Cos(theta) * radius
Dim b As Double = _pll.Lng + Math.Sin(theta) * radius
Next
``````
• What coordinate reference system is your data in? Is the basemap in the same CRS? Commented May 29, 2015 at 16:28
• I have idea, this is `GMaps.Net` and I don't have any idea how to check that. There are no tags for this mapping open source. It does use Bing map as the engine.
– DonA
Commented May 29, 2015 at 16:34

The problem is that your data is in degrees, and a degree of longitude is a shorter distance than a degree of latitude anywhere other than the equator. I am not familiar with GMaps.Net and the projection features it offers but typically one would convert to a projected coordinate system, generate the circle there, and convert back to degrees.

• I don't have an option to convert it to a projected coordinate system - I thought it was in that mode already. Not really sure though.
– DonA
Commented May 29, 2015 at 18:18
• There should be a way with the current math.
– DonA
Commented May 29, 2015 at 19:19

Seems it needed as const aspect to be added to the lat.

``````Dim seg As Double = Math.PI * 2 / segments
Dim aspect As Double = 0.75
For i As Integer = 0 To segments - 1
Dim theta As Double = seg * i
Dim a As Double = _pll.Lat + Math.Cos(theta) * radius * aspect
Dim b As Double = _pll.Lng + Math.Sin(theta) * radius