January 2013
Intermediate to advanced
408 pages
9h 23m
English
You want to zoom in and out of Google Maps.
To zoom in and out of Google Maps, you have three options:
To display the zoom control, you first get an instance of the MapView on your activity’s UI, like this:
package net.learn2develop.maps;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
You then call its setBuiltInZoomControls() method to display the zoom controls for the map. Figure 7-6 shows what the zoom controls look like.
Read now
Unlock full access