我正在寻找 jquery / javascript 中的公式,如果我有一个现有的lat长坐标,我可以使用它来获取新坐标。我在 Google地图上有几个标记我想把它们分开一个均匀的距离。
我拥有的所有标记都具有相同的lat长坐标。我正在看 Haversine Formula 但是我没有看到任何公式可以从现有的lat长坐标对给我新的坐标。
答案 0 :(得分:0)
在一些关于
的研究中找到了这个http://www.movable-type.co.uk/scripts/latlong.html
/**
* Returns the destination point from this point having travelled the given distance (in km) on the
* given initial bearing (bearing may vary before destination is reached)
*
* see http://williams.best.vwh.net/avform.htm#LL
*
* @param {Number} brng: Initial bearing in degrees
* @param {Number} dist: Distance in km
* @returns {LatLon} Destination point
*/
LatLon.prototype.destinationPoint = function(brng, dist) {
dist = typeof(dist)=='number' ? dist : typeof(dist)=='string' && dist.trim()!='' ? +dist : NaN;
dist = dist/this._radius; // convert dist to angular distance in radians
brng = brng.toRad(); //
var lat1 = this._lat.toRad(), lon1 = this._lon.toRad();
var lat2 = Math.asin( Math.sin(lat1)*Math.cos(dist) +
Math.cos(lat1)*Math.sin(dist)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(dist)*Math.cos(lat1),
Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));
lon2 = (lon2+3*Math.PI) % (2*Math.PI) - Math.PI; // normalise to -180..+180º
return new LatLon(lat2.toDeg(), lon2.toDeg());
}