前提:
开发中遇到一个问题。前端创建一个圆。要把经纬度保存在MYSQL空间表中。但是空间数据库只支持点线面。自己上网搜了下。可以根据-180到180度循环。每几个度数,有一个经纬度,创建一个多边形。实现代码JS和MYSQL如下

var ss = [];
function createCoord(coord, bearing, distance)
{
/** http://www.movable-type.co.uk/scripts/latlong.html
φ is latitude, λ is longitude,
θ is the bearing (clockwise from north),
δ is the angular distance d/R;
d being the distance travelled, R the earth’s radius*
**/
var
radius = 6371e3, //meters
δ = Number(distance) / radius, // angular distance in radians
θ = Number(bearing).toRad();
φ1 = coord[1].toRad(),
λ1 = coord[0].toRad();
var φ2 = Math.asin(Math.sin(φ1)*Math.cos(δ) + Math.cos(φ1)*Math.sin(δ)*Math.cos(θ));
var λ2 = λ1 + Math.atan2(Math