Skip to content

Commit

Permalink
atCenterAndRadius method
Browse files Browse the repository at this point in the history
  • Loading branch information
dimik committed Feb 24, 2013
1 parent 3d559ea commit f69c5c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions points-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,26 @@ RandomPointsGenerator.prototype.atBounds = function (bounds) {
};

/**
* TODO
* Генерит случайным образом маркеры внутри окружности с данным центром и радиусом.
* @function
* @name RandomPointsGenerator.atCenterAndRadius
* @param {Number[]} center Координаты центра окружности.
* @param {Number} radius Радиус окружности в метрах.
* @returns {ymaps.Placemark[]} Массив маркеров.
*/
RandomPointsGenerator.prototype.atCenterAndRadius = function (center, radius) {};
RandomPointsGenerator.prototype.atCenterAndRadius = function (center, radius) {
var coordSystem = ymaps.coordSystem.geo,
distance, direction, coords, points = [];

for(var i = 0; i < this.count; i++) {
direction = [Math.random() - Math.random(), Math.random() - Math.random()];
distance = radius * Math.random();
coords = coordSystem.solveDirectProblem(center, direction, distance).endPoint;
points[i] = this.createMarker(coords, i);
}

return points;
};

/**
* TODO
Expand Down

0 comments on commit f69c5c6

Please sign in to comment.