circle overlays appear oval as nearing the poles

1,705 views
Skip to first unread message

awmacgr...@gmail.com

unread,
Aug 6, 2009, 6:58:38 PM8/6/09
to KML Developer Support - Google Earth Plug-in
Hi everyone,

I have plotted a circle (25-sided polygon) at points 0,0 and the
circle is very yummy.

I plot the same circle at point 0,70 (or 70 latitude, 0 longitude) and
the circle appears to be an oval. It is more elongated as the circle's
centre point approaches the pole. Such that if I plot the circle at
0,89 it is essentially a line.

I am using the code (appended below) from Google's KML example
section.

It appears that perhaps this code is calculating points based on a
flat surface, and not one that is on the surface of a sphere.

How can I correct this code to accommodate points approaching poles?

Thanks everyone!

//code:
=======
function createCirclePolygon() {
function makeCircle(radius, x, y) {
var center = ge.getView().copyAsLookAt
(ge.ALTITUDE_RELATIVE_TO_GROUND);

var ring = ge.createLinearRing('');
var steps = 25;
var pi2 = Math.PI * 2;
for (var i = 0; i < steps; i++) {
var lat = 89.12345 + x + radius * Math.cos(i / steps * pi2);
var lng = 0 + y + radius * Math.sin(i / steps * pi2);
ring.getCoordinates().pushLatLngAlt(lat, lng, 0);
}
return ring;
}

var polygonPlacemark = ge.createPlacemark('');
polygonPlacemark.setGeometry(ge.createPolygon(''));
var outer = ge.createLinearRing('');
polygonPlacemark.getGeometry().setOuterBoundary(makeCircle(.05, 0,
0));
ge.getFeatures().appendChild(polygonPlacemark);
}

//endcode

fraser (Earth API Guru)

unread,
Aug 7, 2009, 12:01:58 PM8/7/09
to KML Developer Support - Google Earth Plug-in
Hi,

See the 'Polyplot' example by James Stafford.
You should be able to adapt it easily to your needs.
http://www.barnabu.co.uk/geapi/polyplot/

F.

awmacgr...@gmail.com

unread,
Aug 9, 2009, 11:37:06 AM8/9/09
to KML Developer Support - Google Earth Plug-in
that's fantastic! thanks! :D

On Aug 7, 12:01 pm, fraser (Earth API Guru) wrote:
> Hi,
>
> See the 'Polyplot' example by James Stafford.
> You should be able to adapt it easily to your needs.http://www.barnabu.co.uk/geapi/polyplot/
Reply all
Reply to author
Forward
0 new messages