Traffic and Terrain

Just as the Google Maps you use on your full-size computer can display satellite imagery and, for some areas, traffic information, so too can Android maps.

Figure 63. Map showing satellite view

MapView offers toggleSatellite() and toggleTraffic(), which, as the names suggest, toggle on and off these perspectives on the area being viewed. You can have the user trigger these via an options menu or, in the case of TourMapActivity, via keypresses:

(Override public boolean onKeyDown(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_S) { // Switch on the satellite images map.toggleSatellite(); return(true);

else if (keyCode == KeyEvent.KEYCODE_T) { // Switch on traffic overlays map.toggleTraffic(); return(true);

return(super.onKeyDown(keyCode, event));

The third, default perspective is "street view", which can be turned on via toggleStreetView(). There is also isSatellite(), isTraffic(), and isstreetView() to test to see which of these perspectives is visible.

Self Publishing

Self Publishing

Have you always wanted to write your own book and get it published? Discover How to Write, Print Sell Your Own Book! Have you always wanted to write your own book and get it published? If you have written a book or even if you have a yen to be a writer, you are probably already aware of the competition in the writing field.

Get My Free Ebook

Post a comment