代码之家  ›  专栏  ›  技术社区  ›  Roaders

无法获取要在MapView上显示的缩放按钮

  •  3
  • Roaders  · 技术社区  · 16 年前

    我已经试着把这个看似简单的问题解决了大约半天了。我有一个工作的地图视图,我只想显示默认的缩放关键点,让他们一直在那里。它们一点也不出现——并不是它们出现后就消失了。

    代码:

    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) );
    }
    

    我已经尝试注释掉setZoom,并尝试将setBuiltInZoom控件移动到updateLocation方法。我已经找到了很多关于这个问题的帖子,但是没有一个能解决这个问题。

    2 回复  |  直到 16 年前
        1
  •  3
  •   CommonsWare    16 年前

    仅当用户点击屏幕的相应区域时,缩放控件才会出现。我不知道有什么办法可以强迫他们出现,更不用说永远留在屏幕上了。

        2
  •  0
  •   Denys Séguret    16 年前

    正如Commonware所说,您不能强制控件出现。

    但您可以使用MapController的setZoom方法绘制自己的控件并设置地图的比例。

    推荐文章