Skip to content
Advertisement

Retrieve location from Firebase and put marker on google map

I created the database in Firebase and tried to show the marker in the map. Still not working. what should I do. The app runs but when map activity is opened the app closes. I creates the database manually. I referred this link :- Retrieve location from Firebase and put marker on google map api for android.

This is the code

Map Activity

map.java

JavaScript

This is the Firebase database structure

JavaScript

Logcat

JavaScript

Advertisement

Answer

You are getting the following error:

com.google.firebase.database.DatabaseException: Failed to convert a value of type java.lang.String to long

Because you are trying to get the value of the Latitude property as a Long:

JavaScript

While in your database is stored as a String.

JavaScript

See the equation marks?

To solve this, you should change the type for your Latitude and Longitude properties in the database to be of type double and not String:

JavaScript

And get them accordingly:

JavaScript

The latitude and longitude cannot be long numbers, it should be double and this is because both contain decimals.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement