android - 如何通过城市/国家名称android获取经纬度范围

标签 android google-maps

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

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

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

最佳答案

检查下面的代码

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

关于android - 如何通过城市/国家名称android获取经纬度范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46313069/

相关文章:

java - 为每个商店的多个价格设计数据库结构

java - 从另一个类调用时更改 TextView 的函数不起作用

java - 在 kotlin 中首次构建 Room 数据库时如何修复异常

google-maps - 如何在 Google map 中绘制历史国家数据(苏联、东德等)?

android - 膨胀谷歌地图 v2 fragment 导致 ClassNotFoundException

google-maps - map 错误 : Markers shifting all over the place when switching view angles. 修复了吗?

android - 从图像到 Android 谷歌地图的图 block 生成器

android - 未找到样式属性 attr/colorSecondary

java - 如何以编程方式检查电话号码是否存在?

java - 为什么我的应用程序在启动时不断崩溃 - Android