I wanted to open up a dialog box from the Google Maps View to toggle between the satellite and traffic map layers as shown in the screenshot below.
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
String layer = (String) layers[which]; if (layer.compareToIgnoreCase("traffic")==0){ _mapView.setTraffic(true); _mapView.invalidate(); } else if (layer.compareToIgnoreCase("satellite")==0) { _mapView.setSatellite(true); _mapView.invalidate(); } dialog.dismiss(); }
Later, I found out I could resolve the problem by setting the previous layer to false as shown in the snippet below.
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
String layer = (String) layers[which]; if (layer.compareToIgnoreCase("traffic")==0){ _mapView.setSatellite(false); _mapView.setTraffic(true); _mapView.invalidate(); } else if (layer.compareToIgnoreCase("satellite")==0) { _mapView.setTraffic(false); _mapView.setSatellite(true); _mapView.invalidate(); } dialog.dismiss(); }
No comments:
Post a Comment