2011-11-28 70 views
1

我正在進行GMap自定義。我想要一個浮動圓來移動一條折線。我的問題是,我們是否可以在特定的時間間隔後獲得Polyline中的所有LatLng點,例如,間隔爲100米的所有LatLng。我的折線代碼是:如何獲得折線中兩個端點之間的所有LatLng點

/** polyline **/ 
      var tpath = [ 
        new google.maps.LatLng(15.508718,73.839337), 
        new google.maps.LatLng(15.511457,73.839165) 
       ]; 
      var travelPath = new google.maps.Polyline({ 
       path : tpath, 
       map : map, 
       geodesic : true, 
       strokeColor : '#000', 
       strokeOpacity : 0.7, 
       strokeWeight : 1 
      }); 

我只得到結束LatLng值。我想要通過折線的值。
在此先感謝。

+0

任何人...... ??????? – Suraj

回答

0

您可以使用google.maps.geometry.spherical.computeHeading(startPoint,endPoint)獲取標題

然後計算與google.maps.geometry.spherical.computeDistanceBetween(的startPoint,終點)

的距離如果距離475米和你想〜100跳只是做475 /輪(百分之四百七十五)來計算你想要每次移動該圓的距離。一輪(475/100)會給你多少次(迭代)你應該移動該圈子。

那麼你可以使用computeOffset(來源:經緯度,距離:號,標題:數半徑:數)

那麼你可以使用computeOffset(circleCenter,距離,航向)來獲得新的cirecle中心點在for循環中計算上面計算的迭代量。不要忘記在你的循環中加入延遲。

0

我不知道如何得到它與谷歌地圖API,但你可以畫一條線從手動開始和結束得分。這是一個簡單的數學繪製線和計算。

+0

thnx pal。但我需要與GMap API ..... – Suraj

0

您可以使用GoogleMap.OnPolylineClickListener在Polyline上單擊偵聽器,然後它返回您點擊的多段線。

List<LatLng> mPoints=polyline.getPoints(); 

確保通過設置使您的多段線可點擊。

lineOptions.clickable(true);

相關問題