简体   繁体   English

如何通过Java更改Android GoogleMap上的选项?

[英]How to change options on Android GoogleMap from Java?

I'm trying to add options to my xml-defined google map in my (first!) Android App. 我正在尝试在我的(第一个!)Android App中为我的xml定义的Google地图添加选项。 From Java I now want to change some options. 现在,我想从Java中更改一些选项。 I try to do this as follows: 我尝试这样做,如下所示:

GoogleMap mMap = null; GoogleMap mMap = null;

if (mMap == null) {
    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    if (mMap != null) { 
        Log.wtf("DE MAP IS", "GECREEERD!!!");
        GoogleMapOptions options = new GoogleMapOptions();
        options.mapType(GoogleMap.MAP_TYPE_SATELLITE)
                .compassEnabled(false)
                .rotateGesturesEnabled(false)
                .tiltGesturesEnabled(false);
        mMap.newInstance(options);
    }
}

Unfortunately I get an error at mMap.newInstance(options); 不幸的是,我在mMap.newInstance(options);遇到错误mMap.newInstance(options); saying " The method newInstance(GoogleMapOptions) is undefined for the type GoogleMap ". 说“ 对于类型GoogleMap未定义方法newInstance(GoogleMapOptions) ”。

Does anybody know how I can fix this? 有人知道我该如何解决吗? All tips are welcome! 欢迎所有提示!

use this to select options 使用它来选择选项

int mapType =  GoogleMap.MAP_TYPE_SATELLITE;

FragmentManager manager = getSupportFragmentManager();
SupportMapFragment mapFragment = (SupportMapFragment) manager.findFragmentById(R.id.map);
map = mapFragment.getMap();
map.setMapType(mapType);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM