diff --git a/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt b/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt index a1c5655..fe9f3ea 100644 --- a/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +++ b/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt @@ -29,6 +29,7 @@ import com.google.android.gms.maps.model.MarkerOptions import com.google.android.gms.maps.model.Polygon import com.google.android.gms.maps.model.PolygonOptions import com.google.android.gms.maps.model.PolylineOptions +import com.google.android.gms.maps.model.MapStyleOptions import com.google.android.gms.maps.model.TileOverlayOptions import com.google.android.gms.maps.model.UrlTileProvider import com.luggmaps.LuggCalloutView @@ -120,6 +121,11 @@ class GoogleMapProvider(private val context: Context) : // Theme private var theme: String = "system" + // POI + private var poiEnabled: Boolean = true + private var poiFilterMode: String = "including" + private var poiFilterCategories: List = emptyList() + // Edge Insets private var edgeInsets: EdgeInsets = EdgeInsets() @@ -221,6 +227,7 @@ class GoogleMapProvider(private val context: Context) : applyEdgeInsets() applyInsetAdjustment() applyTheme() + applyPoiStyle() applyUserLocation() processPendingMarkers() processPendingPolylines() @@ -546,11 +553,23 @@ class GoogleMapProvider(private val context: Context) : applyInsetAdjustment() } - override fun setPoiEnabled(enabled: Boolean) {} + override fun setPoiEnabled(enabled: Boolean) { + if (poiEnabled == enabled) return + poiEnabled = enabled + applyPoiStyle() + } - override fun setPoiFilterMode(mode: String) {} + override fun setPoiFilterMode(mode: String) { + if (poiFilterMode == mode) return + poiFilterMode = mode + applyPoiStyle() + } - override fun setPoiFilterCategories(categories: List) {} + override fun setPoiFilterCategories(categories: List) { + if (poiFilterCategories == categories) return + poiFilterCategories = categories + applyPoiStyle() + } // endregion @@ -1299,6 +1318,14 @@ class GoogleMapProvider(private val context: Context) : override fun onTrimMemory(level: Int) {} + private fun applyPoiEnabled() { + val style = if (poiEnabled) null else MapStyleOptions( + """[{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]}, + {"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]}]""" + ) + googleMap?.setMapStyle(style) + } + private fun applyTheme() { val colorScheme = when (theme) { "dark" -> MapColorScheme.DARK diff --git a/docs/MAPVIEW.md b/docs/MAPVIEW.md index 6611e54..c2dc1ff 100644 --- a/docs/MAPVIEW.md +++ b/docs/MAPVIEW.md @@ -36,7 +36,7 @@ import { MapView } from '@lugg/maps'; | `edgeInsets` | `EdgeInsets` | - | Map content edge insets | | `userLocationEnabled` | `boolean` | `false` | Show current user location on the map | | `userLocationButtonEnabled` | `boolean` | `false` | Show native my-location button (Android only) | -| `poiEnabled` | `boolean` | `true` | Show points of interest (Apple Maps only) | +| `poiEnabled` | `boolean` | `true` | Show points of interest. On Android, hides POIs and transit stops via map style. | | `poiFilter` | [`PoiFilter`](#poifilter) | - | Filter POI categories (Apple Maps only) | | `theme` | [`MapTheme`](#maptheme) | `'system'` | Map color theme | | `insetAdjustment` | `'automatic' \| 'never'` | `'never'` | Safe area inset adjustment behavior |