9

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));
}
Flyview
  • 1,899
  • 1
  • 28
  • 46
  • I tried the application on another Jellybean phone and this is not happening. I will investigate further to see if I can find the cause. – Flyview Nov 21 '13 at 20:04
  • can u pls post how u defined LocationFinder?? – Mitesh Shah Dec 05 '13 at 08:57
  • @Mitesh LocationFinder is a huge class with a location listener with logic to determine user location. It returns a LatLng and an accuracy, respectively in those calls. – Flyview Dec 12 '13 at 03:50
  • I'm experiencing this same issue. I've noticed that if I don't clear the map (map.clear) so I get 2 circles the original circle loses it's fill. This used to work fine and the only change I can think of is updating ADT (I'm using Eclipse). – iamgeef Jan 09 '14 at 08:58
  • Did you ever find a fix for this? I'm experiencing the same issue on a 4.3 device. – Jason Schindler Jan 20 '14 at 22:17
  • @Volti No I have not found a solution yet. – Flyview Jan 21 '14 at 04:11
  • Thanks @Flyview. I ended up submitting a bug report to Google. http://code.google.com/p/gmaps-api-issues/issues/detail?id=6267 If anything comes from it I'll post back here. – Jason Schindler Jan 21 '14 at 18:11
  • Hi, i have a similar issue when I change the radius of the circle. It takes a moment before the fill is drawn again. Perhaps you keep updating circle with different accuracy every time. Unfortunately, I have no solution yet. – ferini Feb 13 '14 at 10:01
  • Thanks @Volti ! Please update here or on the Google bug if you have any new information. – Flyview Mar 20 '14 at 16:21
  • I just have the same problem. Simple circle, but when changing the radius, the fill color often disappears :( – s.krueger Mar 26 '14 at 22:18
  • @s.krueger what android version? – Flyview Mar 27 '14 at 11:20
  • @Flyview Android 4.3.1 (CyanogenMod 10.2.0). I just gave up for the moment and removed the filling alltogether :< It didn't even help to clear and readd the circle with every radius change. – s.krueger Mar 27 '14 at 21:52

1 Answers1

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();
}
crazyPixel
  • 2,301
  • 5
  • 24
  • 48
  • I'm not sure I understand. When would I call the invalidate? After panning/zooming the map? That would be a lot of invalidates. The point is the mapview should not "miss" drawing the color fill. – Flyview Mar 27 '14 at 18:50