【问题标题】:Unable to get zoom buttons to show on MapView无法在 MapView 上显示缩放按钮
【发布时间】:2011-01-11 09:14:58
【问题描述】:

我已经尝试解决这个看似简单的问题大约半天了。我有一个工作的 MapView,我只想显示默认的缩放键并一直在那里。它们根本不出现——并不是它们出现然后消失。

代码:

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 方法。我找到了很多与此问题相关的帖子,但没有一个可以解决它。

感谢您的帮助。

【问题讨论】:

  • 那段代码对我来说看起来是正确的——也许它在你的 XML 中?尝试发布,我们可以看看。

标签: android google-maps


【解决方案1】:

缩放控件只会在用户点击屏幕的适当区域时出现。我不知道有什么方法可以强制它们出现,更不用说永久留在屏幕上。

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2012-09-12
      • 2010-10-29
      • 2013-02-17
      • 1970-01-01
      • 2011-10-14
      • 2020-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多