Jodi Jeannette

unread,
Mar 9, 2018, 7:46:03 AM3/9/18
to MIT App Inventor Forum
I have a few students creating an app using the MIT AppInventer 2, and they are hoping to include a location service component which drops a pin to show where a person is in relation to another specific destination-- could someone please help me to help them? I am a n00b teacher doing this for the first time. I can get people whatever other info might help.

Thanks either way.

TimAI2

unread,
Mar 9, 2018, 8:18:43 AM3/9/18
to MIT App Inventor Forum
Sounds like you should do the "Map-it" and "Where's my car?" tutorials  :)


TimAI2

unread,
Mar 9, 2018, 8:23:53 AM3/9/18
to MIT App Inventor Forum
If you are looking to use the built in map component for AI2 the following guide may help:

Jodi Jeannette

unread,
Mar 9, 2018, 9:04:04 AM3/9/18
to MIT App Inventor Forum
Thank you TimAI2, I will be passing this info on to the boys!

SteveJG

unread,
Mar 9, 2018, 9:53:23 AM3/9/18
to mitappinv...@googlegroups.com
The students can do this in several ways.  #1 and #2 are 'complicated,' the tutorials show 'simple' ways.

1.) Using the Google Map Static Map API


The students can show there current location in the Google Static map.   This example is an App Inventor version demonstrating the same example provided by Google showing how to use the Static Map API   https://developers.google.com/maps/documentation/static-maps/intro#quick_example .




There is a demonstration mode and the real life mode in the example.  The demonstration uses the Procedure called StaticMapURLExample.  To run this using the student coordinates, disable the StaticMapURLExample WebViewer blocks in Button1  and enable the StaticMapURL2 blocks next to them.   Also, in the StaticMapURL2 Procedure (the purple blocks), have the students' supply the coordinates of the destination in the Text blocks that have the xxxx text.  Place a latitude in the upper, a longitude in the lower.

The example can be run in an emulator, the real life part requires a real Android device.


For a new user using the Google API is fairly complicated but should not be too difficult if you do the tutorials mentioned by Tim before you try this example.

2) Using the MIT Map component

    Using the Map component gets slightly more complicated.   MIT has yet to provide a tutorial how to do post device and destination location pins  using the Map component. The documentation Tim provided is not for novice App Inventor programmers.  Here are some Forum links if you dare to experiment (there are helpful hints and a few small examples of how to do things)  https://groups.google.com/forum/#!searchin/mitappinventortest/mit$20map$20component%7Csort:date

Later I might post a simple (?) example using the MIT Map component.

Edit:  Here is a simple Map component example:

The Developer must replace the blocks  in the showDestination Procedure that contain the DESTINATION geocoordinates with the appropriate latitude and longitude.
The app does not automatically zoom in or out so If you see only your location on the Map, zoom out to see the red destination marker.

The example use the build in 'location sensor' in the Map component.  That updates the map once about every minute.  The older LocationSensor component can be used with Map 
as described in the documentation.


See the attached aia.  Using Map requires placing objects on the Designer in a particular way so you get a coding 'pass'. and can load the aia to try.  The example MUST be 
tested on a device with Companion or built as an apk.



In my opinion, the easier of the two ways to understand is the Google Map Static Map API.   Easier still is the Where Is My Car tutorial.

3) so perhaps, try these first  
Android, Where's My Car? for App Inventor 2

You parked somewhere near the stadium, but when the concert ends you don't have a clue where the car is. Fortunately you haven't lost your Android phone that never forgets anything, and you remember you have the hot new app, Android, Where's My Car?. With this app, you click a button when you park your car, and the Android uses its location sensor to record the car's GPS coordinates and address. Later, when you reopen the app, it shows you a map from where you are to the remembered location-- problem solved! With this tutorial you'll be able to download a created app and then study the annotated blocks below to better understand the app and App Inventor programming in general. This app covers: GPS, TinyDB, and using Activity Starter to open a map.

Advanced
Map It: Displaying Locations on a Google Map

This tutorial shows how you can develop an app that allows you to record list of addresses and view the address on the Google Maps. It will also show you how view your current location on the Google Map.


Regards,
Steve
MITMapBasic.aia
Reply all
Reply to author
Forward
0 new messages