开发者

Unable to get zoom buttons to show on MapView

开发者 https://www.devze.com 2022-12-18 20:21 出处:网络
I have been trying to get this seemingly simple problem fixed for about half a day now. I have a working MapView and I just want to show the default zoom keys and have them there all the time. They do

I have been trying to get this seemingly simple problem fixed for about half a day now. I have a working MapView and I just want to show the default zoom keys and have them there all the time. They do not appear at all - it's not that they appear then go away.

Code:

public void onCreate( Bundle savedInstanceState ) 
{
    super.onCreate( savedInstanceState );

    setContentView( R.layout.main );

    _altDisplay = (TextView) findViewById( R.id.altitudeDisplay );
    _speedDisplay = (TextView) findViewById( R.id.speedDisplay );
    _accuracyDisplay = (TextView) findViewById( R.id.accuracyDisplay );

    _mapView = (MapView) findViewById( R.id.mapView );
    _mapView.setBuiltInZoomControls(true);

    _mapController = _mapView.getController();
    _mapController.setZoom(22);

    _locationUpdates = new LocationUpdateHandler( (LocationManager) getSystemService( Context.LOCATION_SERVICE) );
    _locationUpdates.addObserver( this );
}

public void updateLocation( GeoPoint point, double altitude, float speed, float accuracy )
{
    _mapController.setCenter(point);

    _altDisplay.setText( "Altitude: " + Double.toString(altitude) );
    _speedDisplay.setText( "Speed: " + Float.toString(speed) );
    _accuracyDisplay.setText( "Accuracy: " + Float.toString(accuracy) );
}

I have tried commenting out the setZ开发者_JAVA技巧oom and tried moving the setBuiltInZoom controls to the updateLocation method. I've found a lot of posts in relation to this problem but none that solve it.

Thanks for your help.


The zoom controls will only appear when the user taps on the appropriate area of the screen. I am not aware of a way to force them to appear, let alone stay permanently on the screen.


As was said by commonsware, you cannot force the controls to appear.

But you may draw your own controls and set the scale of the map using the setZoom method of MapController.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号