2016-07-28 58 views
1

您好我是android開發新手。從開始到目的地的經緯度計算

我在上大學的時候,根據需要在兩點之間找到經緯度列表的位置。 鑑於起始位置是12.990143,80.215784和目標位置是12.992595,80.217618。

Over the past days i search the google, i found so many links to find distance between locations and mid point. I cant able to find solution for my problem. 

Please suggest some solution for this problem. I am struggling over days to find solution for this. 


Thanks in advance 
+0

一個Latlngs兩者之間說點?在一條直線上? –

+0

@GeetChoubey是在直線兄弟 – iyu

+1

檢查這一個:https://developers.google.com/maps/documentation/distance-matrix/intro#travel_modes – Vickyexpert

回答

1

您可以使用從Google Maps API Utility LibrarySphericalUtil.interpolate方法。

例如,你可以找到一個LatLng是在你的起始位置和目的地之間的距離的1/5做

LatLng origin = new LatLng(12.990143,80.215784); 
LatLng destination = new LatLng(12.992595,80.217618); 
LatLng result = SphericalUtil.interpolate(origin, destination, 0.2); 
0

您可以使用谷歌地圖API來獲取的一個完整的折線路徑。您可以objain一個JSON對象並解析它以獲取路徑中的位置。

http://maps.googleapis.com/maps/api/directions/json?origin=12.990143,80.215784&destination=12.992595,80.217618&mode=driving

這將返回一個完整的JSON結果包含您需要找到整個路線落在其上的各點的一切。

你可以看起來更到它:

https://developers.google.com/maps/documentation/directions/intro#Introduction

+0

是的,我試過這個方向api,這是返回道路上的經緯度的路徑。但我需要直線和出口清單位置的經緯度清單。 – iyu