![](/img/trans.png)
[英]How to calculate distance between more than two points with google maps api?
[英]Getting the Distance between Two Points More than Once
我不得不修復有關Google Maps的舊項目,所以這是在V2中。 在我的數據庫中,我已經有數據庫中所有用戶的名字。 然后,系統可以創建某些事件(例如,火災事件)。 現在,該系統應該能夠計算出發生火災時所有用戶的距離,並根據他們與該區域的距離列出所有人員。 我怎樣才能做到這一點? fromAddress應該是人們的位置數組,而toaddress是事件的位置。 邏輯必須類似於下面的代碼
for(i=0;i<fromAddress.length;i++){
gdir.load("from: " + fromAddress[i] + " to: " + toAddress, { "locale": "en" });
distance = Math.round((gdir.getDistance().meters / 1000)*10)/10;
duration = Math.round(gdir.getDuration().seconds/60);
//store distance and duration for output
}
謝謝!
有不同的選項:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.