在googlemaps api v2我在地圖上有一個標記,我需要計算圍繞這一個邊界框。我如何獲得這個標記爲中心的5乘5公里的接合盒?谷歌地圖獲得圍繞標記的邊界框
0
A
回答
2
我不知道,這樣的功能是由谷歌地圖提供的,但數學會幫助你生存的真實的;)Calculate distance, bearing and more between Latitude/Longitude points是很好地參考了不同的地理數據計算。打開該頁面,然後轉到「目標點給定的距離和方位從起點」部分,有公式以及在線計算器,因此您可以檢查它們(以及您可以在地圖上看到的點)。公式有幾個參數:
(lat1,lng1) - your point (marker coordinates)
d - distance (in your case it would be 2.5km)
brng - angle..
找到束縛你需要找到南,北,東,西矩形兩側的座標,所以你會在參數改變一切的角度,對你來說這將是0, 90,180和270名學生。公式:
var lat2 = Math.asin(Math.sin(lat1)*Math.cos(d/R) +
Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng));
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),
Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));
嗯,指定角= 0,你找不着北,PI/2 - 東,PI - 南,3 * PI/2 - 西(角度應以弧度傳遞)。
R = earth’s radius (mean radius = 6,371km)
ADD-ON:只是看着該網頁的源代碼,因爲當我在在線形式軸承進入= 0,距離= 2,那麼我看到映射與兩個點,並根據地圖比例尺他們之間的距離真的是2公里。那麼,你可以用一個簡單的attribution許可使用這個庫,不提供任何擔保明示或暗示的,只是它包含
<script src="http://www.movable-type.co.uk/scripts/latlon.js"></script>
你需要的功能是:
/**
* 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());
}
,當我以在線的形式軸承進入= 0,距離= 2,這種方法與參數執行latLonCalc.destinationPoint(0, "2");
嘗試,否則給我輸入參數,以便我可以檢查出了什麼問題
UPDATE2該庫適用於Grads,並將它們轉換爲弧度進行計算,然後返回到梯度。剛進行的簡單測試:
var latLonCalc = new new LatLon(25, 45);
var point = latLonCalc.destinationPoint(0, "2");
console.info(point);
// prints 25°01′05″N, 045°00′00″E { _lat=25.01798643211838, _lon=45.00000000000005, _radius=6371}
所以入口點到最終目的地的距離有點大於1分鐘;
earth = 2 * PI * 6371; // 40 009.98km
=> 40 009.98km/360grad =~111.14
=> 111,14/60 = 1.85 (km/minute) ~2km
是次的運算,它告訴我,最後一點是,在不遠處則切入點,距離應2公里;)
1
相關問題
- 1. 谷歌地圖半徑圍繞標記
- 2. 圍繞地理座標的邊界框
- 3. 谷歌地圖標記圍繞另一個標記
- 4. 圍繞地理點創建邊界框
- 5. 谷歌地圖邊界多邊形
- 6. 從谷歌地圖獲取匹配的邊界框內的Lon/Lat記錄
- 7. 谷歌地圖請求通過lat-lng邊界框座標
- 8. 移動谷歌地圖v3圍繞
- 9. 設置谷歌地圖邊界與角谷歌地圖
- 10. 如何獲取我的谷歌地圖窗口的邊界框座標
- 11. 谷歌地圖V3信息框 - 擴大地圖邊界?
- 12. Android Google地圖獲得邊界座標
- 13. 如何獲取谷歌地圖的多邊形邊界?
- 14. JSF:JavaScript谷歌地圖API - 標記獲得相同的標題
- 15. 谷歌地圖v3標記信息框
- 16. 谷歌圖表周圍的邊框
- 17. 谷歌地圖:隱藏國家邊界
- 18. 谷歌地圖v3邊界hightlight
- 19. Mongodb geoWithin谷歌地圖邊界
- 20. 谷歌地圖國家邊界
- 21. 谷歌地圖邊界不準確
- 22. 谷歌地圖標記不顯示,因爲邊框
- 23. 谷歌地圖區域邊界的邊界
- 24. 谷歌地圖標記圖標作爲帶邊框的圓形圖片
- 25. 圍繞羣組的邊界
- 26. 谷歌地圖 - 多標記
- 27. 標記在谷歌地圖
- 28. RxJS谷歌地圖標記
- 29. 谷歌地圖標記
- 30. 谷歌地圖標記url
你確定這是100%正確的,如果我用上述公式brng = 0,距離= 2我得到一個超過2公里遠的地方 – nokiko
@nokiko:我更新了我的答案,請看看 – Maxym