问题
I am new to android. I've been trying to apply a field of view to my current location in google map. The image shows a FOV on Google map in iOS.
So basically I did a similar thing by adding 5 triangles with different alpha in order to make the whole fov a gradiant.
I have to update this fov according to azimuth of the device, so I remove those triangles ,recompute them and add them again.
for(int i=0; i<5;i++){
if(triangles[i]!=null){
triangles[i].remove();
}
//triangles=null;
la = mvalues[0]-hang/2;
lx = lon+i*Math.sin(Math.toRadians(la))/2775;
ly = lat+i*Math.cos(Math.toRadians(la))/2775;
ra = mvalues[0]+hang/2;
rx = lon+i*Math.sin(Math.toRadians(ra))/2775;
ry = lat+i*Math.cos(Math.toRadians(ra))/2775;
triangles[i] = map.addPolygon(new PolygonOptions().add(new LatLng(lat,lon), new LatLng(ly,lx), new LatLng(ry,rx)).strokeColor(Color.TRANSPARENT).fillColor(Color.argb(50, 0, 0, 50)));
}
The fov is always blinking, and gc_concurrent always happens. Is it possible to make it not blinking?
Thanks
回答1:
https://developers.google.com/maps/documentation/android/shapes
According to the Google documentation above.
You shall update the shape by calling Polygon.setPoints Link
rather than remove/add.
Hope this would help
来源:https://stackoverflow.com/questions/16667295/dynamically-drawing-polygons-in-google-map