Google Map Polygon with a hole didn’t do well if the zoom level is greater than 19

I am using Android Google Map v2 and MapFragment to display a map. I cover the entire map with a large polygon with a small hole. It works great when the zoom level is less than 19, but after the zoom level reaches 20, the hole is gone. Is this a Google Map bug?

LatLng = (0, 0) enter image description here

LatLng = (25.00, 121.52) enter image description here

LatLng = (25.00, 121.52) MapType = SATELLITE enter image description here

Here is my code, please help. Thank!

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    map.moveCamera(CameraUpdateFactory.zoomTo(18));
    drawPolygonWithHole(map);
}

private void drawPolygonWithHole(GoogleMap map) {
    ArrayList<LatLng> hole = new ArrayList<LatLng>();

    hole.add(new LatLng(-0.0002, -0.0002));
    hole.add(new LatLng(-0.0002, 0.0002));
    hole.add(new LatLng(0.0002, 0.0002));
    hole.add(new LatLng(0.0002, -0.0002));

    map.addPolygon(new PolygonOptions()
        .add(new LatLng(85,90), new LatLng(85,0.1),
             new LatLng(85,-90), new LatLng(85,-179.9),
             new LatLng(0,-179.9), new LatLng(-85,-179.9),
             new LatLng(-85,-90), new LatLng(-85,0.1),
             new LatLng(-85,90), new LatLng(-85,179.9),
             new LatLng(0,179.9), new LatLng(85,179.9))
        .addHole(hole)
        .strokeWidth(0)
        .fillColor(Color.BLACK));
}
+4
source share
1 answer

Google Maps Android API v2. gmaps-api-issues , , AFAIK, .

0

Source: https://habr.com/ru/post/1531821/


All Articles