I want to get the location and then store it in a DB please help me to do so…
Hi Aryan. Welcome.
How to get your Location and put it on a map: here is one way How to put my location on a map
After you capture the latitude and longitude, store it .
You can determine and store to a TinyDB using code like this.
Exactly what you save and how you store the geocoordinates depends on what you want to do with them after you stored them. This code will save the location automatically when your GPS receiver decides you location changes. You can save using a Button instead.
Alternatively, you can save the latitude and longitude to a List and save that List to the TinyDB.
Here are some resources to help you learn to use the AI2 tools. A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .
Also look here http://kio4.com/appinventor/index.htm and here http://www.imagnity.com/tutorial-index/ for more tutorials.
Is this what you wanted to know?
Regards,
Steve
Thanks Steve,
But I am always getting the latitude and longitude to be 0. I have checked all my mobile settings. Please help me to get my latitude and longitude
Why you always get latitude and longitude to 0 is a mystery Aryan. You do not post your code you are using; you did not tell us whether you tried the example code mentioned above so how can we know what the problem is?
- Your device might not have a GPS receiver
- Your device’s location settings might not be set to allow display your location
- You might be testing your app in a building that is attenuating the satellite signals and your device gps cannot get a satellite fix. Go outside and test your app.
- Did you try the code example shown? If you make a project using that code, you will NEVER get the default 0,0 latitude longitude to display. The Android displays 0,0 as a default location. It will display 0,0 if the gps cannot get a satellite fix either because you are not waiting long enough (the first fix might take a minute) or the signals from the satellites are too weak.
- Something you coded is creating problems.
- something else. We cannot see what you are doing unless you share.
Thanks Steve for actively helping me with my doubts!
When I try your code I get nothing in the two text box ( latitude and longitude )
your problem like me, Which country do you come from, because there are certain countries that cannot be detected using normal gps (can only be detected with google gps)
We can help developers when they provide information about their app. You said you get nothing int two text boxes. We do not know because you have not shared anything Aryan.
You do not post your code you are using; you did not tell us whether you tried the example code mentioned above so how can we know what the problem is?
- Your device might not have a GPS receiver
- Your device’s location settings might not be set to allow display your location
- You might be testing your app in a building that is attenuating the satellite signals and your device gps cannot get a satellite fix. Go outside and test your app.
- Did you try the code example shown? If you make a project using that code, you will NEVER get the default 0,0 latitude longitude to display. The Android displays 0,0 as a default location. It will display 0,0 if the gps cannot get a satellite fix either because you are not waiting long enough (the first fix might take a minute) or the signals from the satellites are too weak.
- Something you coded is creating problems.
- something else. We cannot see what you are doing unless you share.
@Salman_Dev Your problem is not the problem Aryan is experiencing. No one knows what your problem might be Salman, because you do not show what you tried and you never told us what your ‘country’ is. Is it Vatican City, Monaco, Nauru, Tuvalu, San Marino, Liechtenstein , Marshall Islands, Saint Kitts, and Nevis, Maldives or Malta? All of these render in OSM tiles. A GPS receiver can detect any location in the World. It is not clear what you mean by “there are certain countries that cannot be detected using normal gps (can only be detected with google gps)”. OpenStreetMap tiles are different from Google’s Map Tiles, that is true. What is your latitude and longitude.
My country is in Poland. In Poland there are some areas that cannot be detected with normal GPS (can only be detected with Google GPS), one of which is my area “Biała Podlaska” which cannot be detected with ordinary GPS.
Thank you.
City co-ordinates: 52°2′N 23°7′E
52.0387, 23.1445
Google Map Tiles do not label Biała Podlaska ; OSM Tiles do label it.
Biała Podlaska is not a country; in many places it would be called a county or a state or some other 'political' subdivision. The GPS can 'find' it.
Don’t you need to be there with a device, to genuinely get a fix ?
My country is the regional poland in Biała Podlaska (Biała Podlaska was in Poland)
I’ve tried normal GPS for detection of my area with family. but the results were not detected
To get a satellite fix, you need a device to capture your device’s current coordinates Tim or be connected to an Arduino that has a GPS receiver.
The LocationSensor can geocode any latitude and longitude pair regardless of the location of the Android device and provide an address (if one is in Google’s database)
To place a Marker on a Google Map or an OpenStreetMap use the LocationSensor (a LocationSensor component must be in your app) to return the latitude and longitude. You need the following blocks where you provide as much address information as you can in the TextBox:
Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map
…this technique works only if you are connected to WIFI or network (because the Google database is consulted to provide the coordinates)… The technique will provide incorrect information if insufficient address information is provided or might not provide an answer if the address is not in Google’s database. 123 Mainstreet might not work but 123 Mainstreet Dallas Tx might or 123 Mainstreet London perhaps.
Is this what you want to do? Get this example to work using a real device (it will not work in an emulator) and then possibly you can get other parts of your app to stop spawning errors.
The Map component, however, can produce a map without a LocationSensor or using a device’s internal GPS receiver by simply inputting a latitude and longitude using
Regards,
Steve
I am from India
Ooo your country should be detected