googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.16k stars 142 forks source link

Holes in Polygon are rendered as other polygons if outside the main area. #596

Closed lucanicoletti closed 4 months ago

lucanicoletti commented 4 months ago

Steps to reproduce

  1. Create a list of points (LatLng) and use it as the points parameter in the Polygon composable function;
  2. Define another list of points (LatLng) where each of those points is outside the area defined by the first list;
  3. Provide the second list to the holes parameter in the Polygon composable function;

Code example

Polygon(
   points = polygonPoints,
   holes = listOf(polygonHole)
)

private val polygonPoints = listOf(
    LatLng(51.508021, -0.075971),
    LatLng(51.483333, -0.119664),
    LatLng(51.50082, -0.143016),
    LatLng(51.517814, -0.1270),
    LatLng(51.532924, -0.10584),
)

private val polygonHole = listOf(
    LatLng(51.523177, -0.085425),
    LatLng(51.523130, -0.057539),
    LatLng(51.531447, -0.080040),
)

Version of the Compose Map used:

com.google.maps.android:maps-compose:5.0.4

Result:

bubenheimer commented 4 months ago

Pretty sure that Google Play maps SDK docs say that the hole must be contained within the polygon bounds

lucanicoletti commented 4 months ago

I would agree with that, I was not sure if this was an error or just a bad usage of the holes parameter. But I also would expect that whenever all the points are outside the boundaries, there would be no drawing. If that's how it is supposed to be, I'll close the issue without problems.

kikoso commented 4 months ago

Hi @lucanicoletti . This is exactly how the underlying Maps SDK work. Since we want to mimic as much as possible, we would not like to change this via android-maps-compose. You can open a feature request in the issue tracker.