Issue
I cant get map view(m) inside my button onclick listner for toggling the views. Could any1 help me.
MapView mapView = (MapView)findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mc = getController();
mc.animateTo(p);
mc.setZoom(10);
Button btn=(Button)findViewById(R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
if (mapView.isSatellite())
{
mapView.setSatellite(false);
mapView.setStreetView(true);
} else
{
mapView.setSatellite(true);
mapView.setStreetView(false);
Solution
In your Activity/Fragment, create a class member variable for your MapView:
private MapView m;
in your onCreate() method, assign this variable the view for MapView:
public void onCreate (Bundle savedInstanceState)
{
m = (MapView)findViewById(R.id.mapView); // the @id setting in your layout of your MapView
.
.
.
}
then you can use m in your button onClick handler
Answered By - CSmith
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.