Labs‎ > ‎

Lab06: Locations and Maps

Wed. Oct 12, 2011

What we will do:

You will use an app, "My Lab Path" to record a number of points along your walk around the Science Center, during lab time today. Then we will try to modify the code of this app, according to the time we have available.

In particular, when the "My Lab Path" starts, the user is presented with the following interface:


Each time a change in the location of the phone is detected, the current latitude, longitude and address are shown on the phone's screen, and the "Remember this Location" button becomes enabled.

  • "Remember this Location" button: When the user decides that she wants to remember the current location, she types in a name (of her choice) to associate with  it. Then she clicks on "Remember this Location" button. She can do this as many times as she wishes during her walk.
  • "Show Path on Map" button: Once clicked, the user is presented with a map of the area, on which the saved locations are shown in red marks.
  • "Pick Visited LatLong" button: (it is actually a Picker). When it is clicked, the user is presented with all the Lat, Long pairs she asked her phone to remember during her walk.
  • "Pick Visited Loc Name": Similarly, when the user clicks this element, a list of all the remembered location names will appear. Once the user has chosen a LatLong pair, or a location name, they will be presented with a map of the area, on which  the selected location will be shown, marked with a red point.
  • "Clear All" button: Of course, the user can choose to "Clear All" data and start anew again at any point.
Notes:
  1. While in the walk, pay attention tot he "network" and "GPS" symbols on the very top of your phone's screen. Be aware of when you have access to a satellite, a wireless network, or both.
  2. Be careful to not click on the "Clear All" button accidentally, as it will obviously clear all data you have collected up until then.
  3. Also, do not click on the "Back" button of your phone while in the opening screen of the app. This will cause the app to quit, and all your data will be lost.
  4. You want your phone to get its location information from satellites, as opposed to the (wireless) network. For this to happen you need to turn on the GPS option on your phone. (Go to: Menu --> Settings --> Security and Location --> Enable GPS Satellites.)
    Also, you need to disable (the check symbol should be grayed out)  the "Use Wireless Networks" option on the same screen as above. 
  5. In order for your phone to be able to contact the google servers, to submit a Map request, your phone needs to have access to the wireless network (since our phones do not have a data plan). So, make sure you see the "network bars" on the top of your screen before your click on any of the "Show Path" or "Pick Visited ..." buttons.
  6. It is worth noticing how different interface elements (the Latitude, Longitude labels, as well as the "Remember" button become enabled/Disabled at different points into the app's execution, in order to facilitate its usage, and guard against possible user input errors.

What we will practice with:

The main goal of this lab is the experience the power of the Global Positioning System (GPS) and the availability of google maps from within your app. In the context of this app, we will have the chance to deal with:
  • Location Sensors
  • Lists, and List Pickers
  • the "Choose" structure
  • using the google maps API

Get started

  • Make sure the GPS option is turned  on your phone. (Go to: Menu --> Settings --> Security and Location --> Enable GPS Satellites.) Also, disable (the check symbol should be grayed out)  the "Use Wireless Networks" option on the same screen as above. 
  • Install the "My Lab Walk" app on your phone.

  • Take your phone out for a walk, and ask it to remember several points along this walk. Once more, do not try to access google maps when you have no access to the wireless network!

A few worth-mentioning points

The "LocationChanged" event is triggered the first time the sensor gets a location reading and each time a location change is detected.

The Google Static Maps API
(Abstract Application Interface) gives you an easy way to include customized maps in your apps. Specifically, it will show you how to build a URL, which will be sent as an HTTP request. The google servers will respond with an image, which you can show in your app.  For each request, you can specify the location of the map, the size of the returned image, the zoom level, the type of map, and the placement of optional markers at locations on the map. You can additionally label your markers using alphanumeric characters. It also points out some tips and tricks in specifying your URLs.

Modifications

Change the app so that it automatically remembers all the different locations detected by the phone. the user should be able to choose any of them to show on a map. However, only the locations that she has saved will be included in the path shown super-imposed on the area map.

ċ
Stella Kakavouli,
Oct 12, 2011, 8:49 AM