Jean Hansen
Jean Hansen

Reputation: 85

Google Maps Android v2 - How to add a hole circle in a polygon?

Does anyone know how to create a hole circle in a polygon with Google Maps Android V2?

Like this https://www.dropbox.com/s/kksr3va2dm87o1q/print.png

I see only hole with array latlong, but I need a hole circle.

mMap.addPolygon(new PolygonOptions()
    .add(new LatLng(0, 0), new LatLng(0, 5), new LatLng(3, 5), new LatLng(3, 0), new LatLng(0, 0))
    .addHole(new LatLng(1, 1), new LatLng(1, 2), new LatLng(2, 2), new LatLng(2, 1), new LatLng(1, 1))
    .fillColor(Color.BLUE));

Thank you!!

Upvotes: 0

Views: 1358

Answers (1)

Chris Broadfoot
Chris Broadfoot

Reputation: 5112

Circles can't have holes. You can generate your own path that's a circle using the spherical functions in the android-maps-utils project.

Specifically, use the SphericalUtil.computeOffset function.

It returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north).

Upvotes: 1

Related Questions