Create Google Map with MVVM Live Data in Fragment with Android Q and Kotlin

preview_player
Показать описание
In this video, I show how to create a Map in a Fragment. The Fragment shares a ViewModel with other Fragments, so that it can observe on LiveData, and update the map when the LiveData changes. To do this, I:
1) Create a new Kotlin fragment with layout
4) The Fragment class will access ViewModel from the activity, and then observe on MutableLiveData that was created earlier.
5) Create an updateMap function, which will add markers to the map. First, it will check to see if the map is ready, and if specimens exist.
6) Invoke updateMap from both the map ready indicator, and the LiveData observation.
7) Demonstrate the map in an emulator.
8) Show that when LiveData changes, the map updates automatically.

Рекомендации по теме
Комментарии
Автор

How would I be able to show or hide markers on the map that are toggled by a checkBox from another activity? I have been trying to do this for a week now but haven't been able to understand it. I keep getting CheckBox must not be null, even after . putBoolean is there something I'm missing, or is there a better way to toggle map markers by category?

darrinreed
Автор

Excellent video, thank you for the awesomely explained content!

kellykarsnia
Автор

Hi ! Maybe have you a video or you can tell me how to remove the marker from the map and firebase by clicking on the marker?

igorvyrvich
Автор

I am lost on how to send the latlng of markers auto-populate to save as a Place object. help!

kaleabwoldemariam
Автор

Hello, do you have by chance some video where you search a location on the map based on it's address? like street name and number with autocomplete in edittext. That's a particularity that I need and I can't find anything close to that anywhere...

starlite
Автор

Can you please allow downloading option?

kaleabwoldemariam
Автор

I've tried a few variations of the map code, using fragment and the element itself, but I keep getting error "Attempt to invoke virtual method 'int on a null object reference"

matthewburdett
Автор

Your contents are amazing. Keep going. 👍Subscriber +=1

subbadajuvlogs
join shbcf.ru