Android Studio中带有底部导航功能的Google Map

时间:2019-05-01 10:21:49

标签: android google-maps bottomnavigationview

我正在Android Studio中开发Android Google Map项目。我有一个MapActivtity可以显示位置(吹漏代码:)

RecyclerView

我的布局是这样的:

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

private GoogleMap mMap;
private LatLng marker;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    // Add a marker in Sydney and move the camera
    LatLng iran = new LatLng(29, 52);

    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(iran, 5.0f));

    addMarker(29.1,52.2,"ssss");
}


public void addMarker(double Lat,Double Lng, String Title){
    marker=new LatLng(Lat,Lng);
    mMap.addMarker(new MarkerOptions().position(marker).title(Title));
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(marker, 10.0f));
    //mMap.moveCamera(CameraUpdateFactory.newLatLng(marker));

}

运行该应用程序时,“地图显示正确”,但是我想使用底部导航在下面的图像中显示“地图”。当选择地图按钮时,将显示地图。 this

0 个答案:

没有答案