AI2Maps103Navigation

 AI2 Maps 103​
​
...the Google Navigation Tutorial for AI2 Navigate with a partnership between AI2 code, ActivityStarter and Google Navigation. The basic code is very simple; the enhancements to turn simple code into an app is also relatively easy. On the way to Yellowstone...or anywhere else.. AI2 Navigate app Directions Screen Trip Map Navigate Screen Build this Thing Few components, the ActivityStarter and a few blocks make this Easy as 1) The Designer Screen 2) The Blocks 3) The App The Designer Screen Lots of layouts and spacer elements are used making it difficult to show how the screen was laid out. Lay it out any way you want. The Blocks The Procedures​
, the most important part of this app:
The ​
navigateToDestination ​
procedure uses the ​
ActivityStarter​
to start Google Navigation with a destination, the current GPS location and the map zoom level. The Location sensor converts an address to coordinates with the ​
coordinatesFromAddress procedure. This converting is called geocoding. The ListView
Selection Index1 Destination using Textbox1 address. NYC is the default. Selection Index2 The White House Selection Index3 MIT Selection Index4 Yellowstone National Park Selection Index5 Paris, France (only will render in Europe) Selection Index6 London, England (only will render in British Isles) The ListView controls the source of the destination address information. The app can use an actual address (as in Selection Index1) or use geocoordinates (as in the other options). The LocationSensor The ​
LocationSensor​
connects the app to the built­in GPS receiver in the device. Initialize
Set the ​
ListView.ElementsFromString​
using a csv text string corresponding to the locations in the ListView. The Buttons Button6 and Button7 increase or decrease the map zoom level. In the aia file, Button1 and Button2 are disabled..the code shows how to call the procedures using buttons. The Variables and the rest of the blocks
The app needs placeholders for the GPS location and the destination and a destination List. The ​
AI2 Navigate​
App Make sure your Location permissions are set and the GPS receiver enabled.
To geocode you must allow Google to have access to your location information. Run the app. The User can either enter an address or select a precoded location. Select a Destination using the red ListPicker options. After a few seconds on WIFI (and perhaps longer on a G3/G4 network) the ​
Directions​
screen appears. Touch the small map to see a large map. To navigate instead, select ​
START NAVIGATION​
(located immediately below the small map) and wait. It takes a while for Google to set up Navigate, especially when using a network connection. A User can also start navigation from the large map by pressing the black arrow in the blue circle icon in the right lower corner of the map. Use Google Navigate to find your way. Be careful, this feature is experimental. Do not drive into lakes or off bridges please. Google Navigate Is Google Navigate available everywhere? I do not know...try the app, it works in North America. Google has a very aggressive mapping program. Google mapping software changes on a monthly basis. Look for new features and the possibility of discontinuance of some features when using Navigate that could affect the programming of your navigation app. Is an aia File included? Look for AI2_Navigate_template.aia on the main blog page. The aia source file is the a template aia. Are you done yet? 1) There is no database in ​
AI2 Navigate​
. Add a ​
TinyDB​
to store user input destinations and provide a MENU and code to retrieve the information. 2) Printed directions? Use the Google Location API using the Web control and parse the result to get detailed directions for long or complex routes. 3) The destination list is created with hard coded coordinates. Use the ​
File​
control and a csv table to provide flexibility in posting destinations in the ​
ListView​
. 4) Did you do something clever that you would like to share...perhaps post the code in the MIT Gallery? (Yes, you may post versions of AI2 Navigate that has a very different user interface in the Gallery). Important Facts This tutorial and the app are copyrighted. Please do not slightly modify this tutorial and claim it as your own or post it on ​
Google Play​
. Have fun with the ​
AI2 Navigate​
for personal use, use the algorithms and ideas in your own app and enjoy coding. Make you own user interface and do whatever you want with the code. This tutorial, images and ​
AI2 Navigate​
are Copyright ​
© 2​
015 by SJG. Some images might be Copyright Google Maps.