我正在使用GoogleMap片段使用標記顯示一些位置數據。我想要做的是,在地圖上繪製一個具有特定距離半徑的圓,以便該圓將近似地覆蓋地圖上的某個區域。我不知道從哪裏開始,我已經有一個地圖顯示位置數據,從位置數據我可以找出這些點距離中心位置的距離。如何在地圖上繪製一個覆蓋特定距離的圓圈
任何幫助將是偉大的。
我正在使用GoogleMap片段使用標記顯示一些位置數據。我想要做的是,在地圖上繪製一個具有特定距離半徑的圓,以便該圓將近似地覆蓋地圖上的某個區域。我不知道從哪裏開始,我已經有一個地圖顯示位置數據,從位置數據我可以找出這些點距離中心位置的距離。如何在地圖上繪製一個覆蓋特定距離的圓圈
任何幫助將是偉大的。
CircleOptions circleOptions = new CircleOptions()
.center(new LatLng(37.4, -122.1))
.radius(1000)); // In meters
// Get back the mutable Circle
Circle circle = myMap.addCircle(circleOptions);
有關詳細信息檢查:https://developers.google.com/maps/documentation/android-api/shapes
使用GoogleMap Circle API。您只需要通過必需的輸入並完成。從示例中關注鏈接。 e.g從文檔,簡單的代碼結構看起來像這樣
Circle circle = map.addCircle(new CircleOptions()
.center(new LatLng(-33.87365, 151.20689)) // center point of map
.radius(10000) // radius of circle to cover on map
.strokeColor(Color.RED) //color of circle boundary
.fillColor(Color.BLUE)); //color of circle to fill ,
// make sure choose the light color close to transparent
使用此功能,你需要通過
LatLng
爲paramater
,當你調用它。
private void drawCircle(LatLng point){
CircleOptions circleOptions = new CircleOptions();
// Specifying the center of the circle
circleOptions.center(point);
// Radius of the circle
circleOptions.radius(20);
// Border color of the circle
circleOptions.strokeColor(Color.BLACK);
// Fill color of the circle
circleOptions.fillColor(0x30ff0000);
// Border width of the circle
circleOptions.strokeWidth(2);
// Adding the circle to the GoogleMap
googleMap.addCircle(circleOptions);
}