[英]How do I create a pair of longitude and latitudes to show a 2 mile radius of a particular longitude and latitude? in Java Android
[英]How do I figure out longitude and latitude coordinates to create a 1 mile radius around a user's location?
如何計算經度和緯度坐標以在用戶位置周圍創建1英里半徑? 我不介意它需要多少個坐標,但我想圍繞一個位置創建一個圓形半徑。
例如:
如果用戶的位置是=
Latitude: 44.947 Longitude: -93.098
然后,我如何確定8組經度和緯度坐標在上述位置周圍創建1英里半徑。
(上面例子中的8是斜體,因為我不介意它是否小於或大於8)
我該怎么做呢?
代碼到目前為止:
LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
double longitude = location.getLongitude();
double latitude = location.getLatitude();
雖然我很高興人們正在努力幫助,但下面給出的答案並沒有回答這個問題。
請記住,我沒有Android經驗,所以如果這不適用,請忽略我。
使用Web版本,實現所需內容的最簡單方法是使用繪圖API創建一個以您的用戶位置為中心的半徑圓(在本例中為一英里)。 然后,您可以使用內置方法查找此對象的角點邊界(不幸的是矩形),以便為您提供所需的長/拉。
如果要在地圖上創建圓,請執行以下操作:
1)獲取地圖片段的引用:
GoogleMap = MyMap;
MyMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map_id)).getMap();
2)繪制圓圈:
MyMap.addCircle(new CircleOptions().center(new LatLng(latitude,longitude)).radius(0.00062).fillColor(0x88000000).strokeColor(0x44000000).strokeWidth(2));
1米= 0.000621371英里
如果您不知道如何使用Google Maps API v2,請點按此鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.