14.01.2013 Views

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

Android™ Application Development - Bahar Ali Khan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7: Maps, Geocoding, and Location-Based Services<br />

226<br />

android:layout_height=”fill_parent”<br />

android:enabled=”true”<br />

android:clickable=”true”<br />

android:apiKey=”mymapapikey”<br />

/><br />

<br />

At the time of publication, it was unclear how developers would apply for map keys.<br />

Invalid or disabled API keys will result in your MapView not loading the map image<br />

tiles. Until this process is revealed, you can use any text as your API key value.<br />

Figure 7-5 shows an example of a basic map-based Activity.<br />

Figure 7-5<br />

Android currently recommends that you include no more than one MapActivity and one MapView<br />

in each application.<br />

Confi guring and Using Map Views<br />

The MapView class is a View that displays the actual map; it includes several options for deciding how<br />

the map is displayed.<br />

By default, the Map View will show the standard street map, as shown in Figure 7-5. In addition, you can<br />

choose to display a satellite view, StreetView, and expected traffi c, as shown in the code snippet below:<br />

mapView.setSatellite(true);<br />

mapView.setStreetView(true);<br />

mapView.setTraffic(true);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!