I would like to draw a ring 20km thick with empty 5km circle inside. I dont how how to do it. I believe it is possible.
One simple solution could be to substract one
Here's a slightly modified version of geocodezip's answer using the geometry library:
function getCirclePoints(center, radius, numPoints, clockwise) {
var points = [];
for (var i = 0; i < numPoints; ++i) {
var angle = i * 360 / numPoints;
if (!clockwise) {
angle = 360 - angle;
}
// the maps API provides geometrical computations
// just make sure you load the required library (libraries=geometry)
var p = google.maps.geometry.spherical.computeOffset(center, radius, angle);
points.push(p);
}
// 'close' the polygon
points.push(points[0]);
return points;
}
You can use it like this:
new google.maps.Polygon({
paths: [
getCirclePoints(yourCenter, outerRadius, numPoints, true),
getCirclePoints(yourCenter, innerRadius, numPoints, false)
],
/* other polygon options */
});
Edit:
The geometry API can be added in Node like this (thanks to Gil Epshtain):
require('google-maps-api')(GOOGLE_API_KEY, ['geometry'])
By the time I was writing this, I used plain old JavaScript inclusion in HTML: