2017-09-20 68 views
2

我正在google map中搜索特定城市的緯度和經度範圍。我拿到了印度國家名稱的例子。如何獲取城市/國家名稱的經緯度範圍android

private static final LatLngBounds BOUNDS_INDIA = new LatLngBounds(new LatLng(23.63936, 68.14712), new LatLng(28.20453, 97.34466)); 

現在,我想爲我選擇的國家設置它。哪裏可以找到特定區域的兩點經緯度。

+0

https://stackoverflow.com/questions/4873076/get-latitude-and-longitude-from-city-name –

+0

https://stackoverflow.com/questions/ 3574644 /我怎麼能找到緯度和經度從地址 –

+0

通過這些鏈接 –

回答

0

檢查下面的代碼

String location=cityName; 
String inputLine = ""; 
String result = "" 
location=location.replaceAll(" ", "%20"); 
String myUrl="http://maps.google.com/maps/geo?q="+location+"&output=csv"; 
try{ 
URL url=new URL(myUrl); 
URLConnection urlConnection=url.openConnection(); 
BufferedReader in = new BufferedReader(new 
InputStreamReader(urlConnection.getInputStream())); 
    while ((inputLine = in.readLine()) != null) { 
    result=inputLine; 
    } 
    String lat = result.substring(6, result.lastIndexOf(",")); 
    String longi = result.substring(result.lastIndexOf(",") + 1); 
} 
catch(Exception e){ 
e.printStackTrace(); 
} 
+2

OP是問他如何獲得一個特定地區的經度和緯度,而不是一個特定的緯度地址和經度 –

+1

錯誤的答案。先閱讀問題。 –

+0

使用google map api查看我編輯的代碼 –

相關問題