上绘制新的之前我有这样的方法:删除以前的圆圈标示
public void crowdArea(){
for (int n=0; n<place.length; n++) {
Location locationFromDB2 = new Location("");
locationFromDB2.setLatitude(latt2[n]);
locationFromDB2.setLongitude(longg2[n]);
total = 0;
double c [][]=new double[100][2];
double p [][]=new double[100][2];
for (int n2 = 0; n2 < latt.length; n2++) {
Location locationFromDB3 = new Location("");
locationFromDB3.setLatitude(latt[n2]);
locationFromDB3.setLongitude(longg[n2]);
float dist = locationFromDB2.distanceTo(locationFromDB3);
if (dist < 500f) {
c [total][0]=latt[n2];
c [total][1]=longg[n2];
p [total][0]=prelatt[n2];
p [total][1]=prelongg[n2];
total++;
}
}
if (total >= 5) {
draw(latt2[n], longg2[n]);
state[n]="yes";
boolean b=bearing2(c,p);
Log.d("diriction is: ", b+"");
}
else{
state[n]="no";
// draw2(latt2[n], longg2[n]);
}
}
}
public void draw(double lat, double lonng){
Circle myCircle;
LatLng lt=new LatLng(lat, lonng);
CircleOptions circleOptions = new CircleOptions()
.center(lt) //set center
.radius(500) //set radius in meters
.fillColor(0x40ff0000) //default
.strokeColor(Color.RED)
.strokeWidth(5);
myCircle = map.addCircle(circleOptions);
}
借鉴了我的地图了一圈。 这个方法每15秒调用一次,但它在前一个圆上绘制一个圆,等等。我想要的是删除之前的圈子,然后再添加新的圈子。
该怎么办?
但这也会清除地图上的所有标记 – LamaTat
是否有一种方法可以保留标记并仅删除圆圈? – LamaTat
好吧,它工作正常。但是每次调用方法时我都绘制了多个圆圈,使用这将只保留一个圆圈。你可以请检查我的代码我更新它。 – LamaTat