百度地圖自定義繪製的方法
阿新 • • 發佈:2019-02-01
百度地圖中的自定義繪製
圓的繪製方法
CurcleOptions center(LatLng center) 設定圓心座標
extraInfo(Bundle extraInfo) 設定圓額外資訊
fillColor(int color) 設定圓填充顏色
radius(int radius) 設定圓半徑
stroke(Stroke stroke ) 設定圓邊框資訊
visible(boolean visible) 設定是否可見
zIndex(int zIndex) 設定圓zIndex資訊
LatLng getCenter() 獲取圓心座標
Bundle getExtraInfo() 獲取圓額外資訊
int getFillColor() 獲取填充色
getZIndex() 獲取圓zIndex資訊
getRadius() 獲取圓的半徑
Stroke getStroke() 獲取圓邊框資訊
boolean isVisible() 獲取圓是否可見
在百度地圖上繪製一簡單的圓
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_geo);
mapView=findViewById(R.id.bmapView);//初始化MapView
mbaiduMap=mapView.getMap();//通過mapview的getMap方法獲取地圖
setMapView();
}
private void setMapView(){
OverlayOptions centrePolyine=new CircleOptions()
.center(new LatLng(39.99999,115.35888))//圓心位置坐標
.stroke(new Stroke(10,0xAA00FF00))//設定圓邊框資訊
.radius(10000)//設定圓的半徑
.fillColor(0x000000FF);//設定圓的填充色
mbaiduMap.addOverlay(centrePolyine);
}
折線的繪製方法
//普通折線繪製
LatLng p1 = new LatLng(39.97923, 116.357428);
LatLng p2 = new LatLng(39.94923, 116.397428);
LatLng p3 = new LatLng(39.97923, 116.437428);
List<LatLng> points = new ArrayList<>();
points.add(p1);
points.add(p2);
points.add(p3);
OverlayOptions ooPolyline = new PolylineOptions()
.width(10)//設定線的寬度
.color(R.color.colorAccent)//設定線的顏色
.points(points);
mbaiduMap.addOverlay(ooPolyline);
現在還有待擴充套件,日後再續