Lab Session: Play with Features: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "In this lab, you will add a compass to your application, allow it to pull weather data by your location, and have it choose a random location on shake.")
 
No edit summary
Line 1: Line 1:
In this lab, you will add a compass to your application, allow it to pull weather data by your location, and have it choose a random location on shake.
In this lab, you will add a compass to your application, allow it to pull weather data by your location, and have it choose a random location on shake.
== Student Outline ==
The following lab contains three parts.
=== Compass ===
Using the resources and code from the Compass sample, add a compass to ''frmCompass'' in your app.
=== Geolocation ===
# Attach an onchange event to ''flpCurrentLocation''.  When it is switched to On, you should retrieve the current location using [[https://developer.mozilla.org/en-US/docs/Web/API/Geolocation.getCurrentPosition navigator.geolocation.getCurrentPosition]], and disable ''txtCity'' and ''btnLoad''.  When switched to off, ''txtCity'' and ''btnLoad'' should be re-enabled.
# When the current location has been retrieved, enable ''btnLoad''.
# When ''btnLoad'' is pressed and ''flpCurrentLocation'' is in the On position, load the weather information via latitude and longitude, using the following API: http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139
=== Accelerometer ===
# A shaking motion can be sensed by setting a threshold for accelerometer activity.  Experiment to determine what an acceptable threshold is for your device.
# When on ''frmMain'' listen for accelerometer events that could indicate a shaking motion and set the location to a random latitude and longitude and load weather for that location.

Revision as of 05:36, 13 December 2013

In this lab, you will add a compass to your application, allow it to pull weather data by your location, and have it choose a random location on shake.

Student Outline

The following lab contains three parts.

Compass

Using the resources and code from the Compass sample, add a compass to frmCompass in your app.

Geolocation

  1. Attach an onchange event to flpCurrentLocation. When it is switched to On, you should retrieve the current location using [navigator.geolocation.getCurrentPosition], and disable txtCity and btnLoad. When switched to off, txtCity and btnLoad should be re-enabled.
  2. When the current location has been retrieved, enable btnLoad.
  3. When btnLoad is pressed and flpCurrentLocation is in the On position, load the weather information via latitude and longitude, using the following API: http://api.openweathermap.org/data/2.5/weather?lat=35&lon=139

Accelerometer

  1. A shaking motion can be sensed by setting a threshold for accelerometer activity. Experiment to determine what an acceptable threshold is for your device.
  2. When on frmMain listen for accelerometer events that could indicate a shaking motion and set the location to a random latitude and longitude and load weather for that location.