Getting Ready

The first thing we need to do is call findViewById() to get access to the MapView and its container. We can do that in the initMapView() method:

Download MyMap/src/org/example/mymap/

private void initMapView() {

map = (MapView) findViewById(; controller = map.getController(); map.setSatellite(true); map.setBuiltInZoomControls(true);

The getController( ) method returns a MapController that we'll use to position and zoom the map. setSatellite() switches the map into satellite mode, and setBuiltInZoomControls()8 turns on the standard zoom controls. The MapView class will take care of making the controls visible when the user pans the map and will take care of fading them out slowly when panning stops.

The last step is to tell the MapView to follow your position in the initMy-Location( ) method.

8. Introduced in Android 1.5.

0 0

Post a comment