如何在google map api中设置默认标记位置

如何在google map api中设置默认标记位置,api,google-maps,google-chrome,google-apps-script,google-api,Api,Google Maps,Google Chrome,Google Apps Script,Google Api,我正在使用谷歌地图API,我想设置默认的lat和long in标记。我有一个位置,我想在加载地图时默认打开该位置,然后它应该作为设置位置打开。如何实现这一点?将其写入mapReady函数中 @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // enter the latitude and longitude in place of -35,151 respectively

我正在使用谷歌地图API,我想设置默认的lat和long in标记。我有一个位置,我想在加载地图时默认打开该位置,然后它应该作为设置位置打开。如何实现这一点?

将其写入mapReady函数中

    @Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // enter the latitude and longitude in place of -35,151 respectively
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}