I am drawing a couple of circles in a mapFragment using Google Maps V2 in android. Everything was peachy with V1 but after the switch, the fill color of my circles isn't always drawn.
For example I open the map, the circle is there and filled, but if I zoom a couple times the fill color disappears. I zoom back out and it's still gone (or it may re-appear). I haven't been able to pinpoint what behavior causes it to disappear, sometimes it isn't even there to begin with and zooming around causes it to appear.
Here's some code of one of my circles:
private void addAccuracyCircle() {
accuracyCircle = map.addCircle(new CircleOptions()
.center(LocationFinder.getActualPoint())
.radius(LocationFinder.getActualLocation().getAccuracy())
.fillColor(Color.argb(10, 0, 50, 240))
.strokeColor(Color.argb(50, 0, 50, 240))
.strokeWidth(2)
.zIndex(1));
}
You should try and do a map.invalidate() on the map view - the reason that happen might be that upon zoom in\out and navigating in the map - the mapview object renders itself again and "miss" drawing your color fill, I had a similar problem and to solve it I wrote a refresh method which clear the controls on the map->invalidate->redraw controls on the map->invalidate might be a little messy but it worked for me.
(something like) -
protected void RefreshMap() {
map.getOverlays().clear();
map.invalidate();
// Use a list of itemize overlay here and add all the objects
//from that list upon refresh
map.invalidate();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With