什么是印度的LatLngBounds?

时间:2016-08-18 08:25:36

标签: android google-maps google-places-api latitude-longitude

我在Android应用程序中使用自动完成位置小部件。我想把限制只限于印度。但我不知道印度的LatLngBounds。有人对坐标有任何想法吗?

4 个答案:

答案 0 :(得分:12)

你可以使用它..

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

答案 1 :(得分:7)

如果你想覆盖整个印度(虽然它也会覆盖中国,巴基斯坦和孟加拉国的某些地区),请使用以下范围: -

public static final LatLngBounds BOUNDS_INDIA = new LatLngBounds(new LatLng(7.798000, 68.14712), new LatLng(37.090000, 97.34466));

根据谷歌文档: -

public LatLngBounds (LatLng southwest, LatLng northeast)

Creates a new bounds based on a southwest and a northeast corner.

The bounds conceptually includes all points where:

1. the latitude is in the range [northeast.latitude, southwest.latitude];
2. the longitude is in the range [southwest.longtitude, northeast.longitude] if southwest.longtitude ≤ northeast.longitude;

查找任何地方的经纬度 使用: - http://www.findlatitudeandlongitude.com/

答案 2 :(得分:2)

您可以使用此API获取任何国家/地区的范围

https://maps.googleapis.com/maps/api/geocode/json?key=YOUR_API_KEY&address=india

将您的密钥放在YOUR_API_KEY的位置,在国家/地区的地址

您将得到与此类似的回复

  {
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "India",
               "short_name" : "IN",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "India",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            },
            "location" : {
               "lat" : 20.593684,
               "lng" : 78.96288
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 35.513327,
                  "lng" : 97.39535869999999
               },
               "southwest" : {
                  "lat" : 6.4626999,
                  "lng" : 68.1097
               }
            }
         },
         "place_id" : "ChIJkbeSa_BfYzARphNChaFPjNc",
         "types" : [ "country", "political" ]
      }
   ],
   "status" : "OK"
}

在几何边界中你得到sountwest和东北边界只是使用它们

private static final LatLngBounds BOUNDS_INDIA = new LatLngBounds(
       new LatLng(6.4626999, 68.1097),
       new LatLng(35.513327, 97.39535869999999)
     );

答案 3 :(得分:1)