使用 google 地图时 OnClick 方法未激活

OnClick method doesn't activate while using google maps

在我的 android 应用程序中使用 google 地图时,我遇到了一个问题:

我想在单击 textView 时移动相机和缩放(激活 moveToSlo 方法)。

方法是这样的:

public void moveToSlo(View v){
    slovenia = new LatLng(46.1491664, 14.9860106);
    slo = CameraUpdateFactory.newLatLngZoom(slovenia,8);
    map.moveCamera(slo);
}

但是它说它无法解析 moveCamera 方法。

我可能遗漏了什么,但我不知道是什么。

尝试使用

map.animateCamera(CameraUpdateFactory.newLatLngZoom(slovenia, 8));

并仔细检查您是否像这样初始化了 mapFragment

SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

然后获取地图本身

map = fm.getMap();