【问题标题】:How to get latitude and longitude bounds by city/country name android如何通过城市/国家名称android获取纬度和经度范围
【发布时间】:2017-09-20 04:00:18
【问题描述】:

我正在谷歌地图中搜索特定城市的纬度和经度范围。我得到了为国家名称印度实施的示例。

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

现在,我想为我选择的国家/地区设置它。在哪里可以找到特定区域的纬度和经度这两个点。

【问题讨论】:

标签: android google-maps


【解决方案1】:

检查以下代码

 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();
 }

【讨论】:

  • OP 询问他如何获取特定区域的纬度和经度,而不是特定纬度和经度的地址
  • 使用google map api查看我编辑的代码
猜你喜欢
  • 2014-04-14
  • 1970-01-01
  • 2013-12-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多