With LocationSensor component you can build an app that can provide you with your current location information. Say you are going to some place you are not familiar with. We will create an app where you can save your current location and then go where you need to go, if you think you are lost along the way, the app can show you how far you have come from the point when you saved your last location information. We will name that app – Where Am I. This is how our app would look like-
Let’s build our interface in the Designer/Viewer window. On your browser, go to My Projects and create a new app. Name it whatever you like. I named it WhereAmI.
The design view of our app should look somewhat like this-
As you can see I renamed default names of some of the components App Inventor provides. It’s upto you what you want to name the components you use. If you are having hard time designing the UI, download the source file WhereAmI and take a look. What matters is that you have all the essential components as shown in the UI screenshot above.
LocationSensor has an event called LocationChanged that gets triggered every time location changes which can be triggered by a user movement. We use that event to get and display current location information. We also change our canSave variable’s value to true so that the user would be able to save their current location information later on a TinyDB. When the user asks to save the information on current location, we first check if there is any location information by checking the value of canSave variable. If there is, we store the value of current address, latitude, and longitude in tiny db with unique tags. We will need those tags to retrieve the saved values. If we don’t have any location information, we simply notify the user stating so.
What we need to do when our app loads on a device is to show the previously saved location information. We can get those values from tiny db using the tags we used to save in SaveButton.Click event. Note that Screen1.Initialize event is the first event that gets triggered when an app boots up on a device. In that event, we also set the Action, ActivityPackage, and ActivityClass properties of our ActivityStarter component so that we can launch Google Map on a web browser.
You can see a list of actions in this page.
Finally, we need to form our map address to launch the browser with. If they stored a location information, we would show the direction using their current location and the location they saved.
We used make text to build the URL. saddr points to user’s current location and daddr points to user’s previous saved location. For both, we need to pass Latitude and Longitude respectively with a comma in between. If no previous location is saved, the map would display with the default latitude and longitude we provided which is 1000. You can put any default values you prefer. Note that our URL is attached to DataUri property of the ActivityStarter. After we are done forming the URL, we simply start our ActivityStarter.
And..we are DONE!
Here’s the project file for download- WhereAmI
Hello …hope you doing well
First I would like to thank you so much for this tut…
And I was wondering if you wanted to calculate the distant between both points and time…where it would show in a lable time and distant upon driven .
Thank you so much in advance
Hello, I’m trying to make only the first part, showing my current address into the address label, but I don’t understand how don’t work this firts step.
Thank you
Please test on a device. This doesn’t work on an emulator.
Sir, I am not able to get the current Location in the Where I am App as well as Previous Location. Rest all things are working fine
hello, I have an idea for an app but I’m not a programmer and need somebody with experience to develop it. please contact me if you are interested.
thank you
but is it possible to show the map in the app so with web viewer that you dont have to open google maps?
Can you show how make an application that send the latitude and longitude via sms?
See here: http://explore.appinventor.mit.edu/no-text-while-driving-ai2
How to calculate the distance between my location to a given place(location) using latitude and longitude automatically.
This will be done when clicking on a button i.e “Distance from here”. The user will not be asked to give latitude or longitude.
http://stackoverflow.com/questions/1502590/calculate-distance-between-two-points-in-google-maps-v3
why activity starter not found
Sire, please can you (If you have time) make a tutorial on youtube or on your website so it will be easier what you are doing and make most of other people’s understandings clearer.
Kind Regards
great
How to calculate the distance between my location to a given place(location) using latitude and longitude automatically.
This will be done when clicking on a button i.e “Distance from here”. The user will not be asked to give latitude or longitude. in MIT App Inventor
Excuse me, sir. Can I have your email address ,I have few question to ask
HI , I WANT TO MAKE AN APP NAMED MYBUS TRACKER . I WANT TO TRACK MY BUS USE GOOGLE MAPS AND I WANT GET NOTY HOW LONG TIME MYBUS WILL ARRIVE AT MY PLACE . CAN YOU HELP ME SIR ?
Hi,
do you know how I can add google street view into app inventor ? I would like to have a view of 3d street inside the application correlated with my GPS position. No flat 2d map but 3d with street view.
Like this-
https://appinventor.mit.edu/explore/content/map-tour-part-2
Hello Sajal Dutta.
I have a question for you.
Can we make a log file for the places we (Save) –for — (savecurrentlocation)s
i must to do a continous procedure of walking in the field and i need to store the lat and long, and the amount of walking step i made. (for the steps i have solved).
I do not want to export like a share, i want to store all the times i click in a button in the app and then check what places they are (generally a rect line or with a little deviation), all the places, stores in a log file like a “walking.txt”
Sorry for my english, i am spanish talker.
And my project is for mapping botanical species in the field, there are no kind of mapping tool there for my job, and i do A LOT OF TIMES is very repetitive, and i need to solve it, for make better results.