2017-09-20 4 views
2

私は特定の都市のGoogleマップで緯度と経度の境界を検索しています。私は国名Indiaの実装例を得ました。都市/国名で緯度と経度の境界を取得する方法android

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

今、私は選択した国に設定したいと思います。特定の地域の2つの緯度と経度をどこで見つけるか。

+0

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

+0

https://stackoverflow.com/questions/ 3574644/how-can-i-find-the-latitude-and-longitude-from-address –

+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マップのAPIを使用すると、編集したコードが表示されます –

関連する問題