I am trying to style my map that i hace implemented in my application. The map is working fine, but when i tried to put a style on it, it produces an error.
These are the lines that are relevant to the problem:
fun MapViewContainer(modifier: Modifier = Modifier, currentLatLng: LatLng) {
val context = LocalContext.current
val mapView = remember {
MapView(context).apply {
onCreate(Bundle())
getMapAsync { googleMap ->
googleMap.addMarker(MarkerOptions().position(currentLatLng).title("Localització Actual"))
googleMap.uiSettings.isZoomControlsEnabled = true
googleMap.uiSettings.isZoomGesturesEnabled = true
googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), res.raw.map_style))
there are some parameters more, but those work fine. The problem is that it says there is an unresolved reference to res.raw.map_style, but that file does exist. I include an image:
image of the structure of the project
I hace tried to rebuild and reset Android Studio, but nothing seems to work. If someone can provide a solution, i would be very grateful. Thank you!!
Use it like googleMap.setMapStyle(MapStyleOptions.loadRawResourceStyle(getContext(), R.raw.map_style)
Instead of res.raw You should use R.raw