简体   繁体   English

android java - 如何在 Google 地图 api 的折线中设置可见性 false 和 true?

[英]android java - How do you do to set visibility false and true in a Polyline on Google Maps api?

Hello World im new programming...你好世界我新的编程...

i am creating a trip app...我正在创建一个旅行应用程序...

i have an Activity with LinearLayout that contains 6 ImageButtons, and after the LinearLayout there is a FrameLayout with Google Maps;我有一个包含 6 个 ImageButtons 的 LinearLayout 活动,在 LinearLayout 之后有一个带有 Google Maps 的 FrameLayout; in the logical part there are 6 Polylines, all of these Polylines have.visible(false)在逻辑部分有 6 条折线,所有这些折线都有.visible(false)

i would like click in 1 ImageButton and get 1 Polyline set.visible(true) and if i click again the ImageButton set that Polyline.visible(false)我想点击 1 ImageButton 并获得 1 Polyline set.visible(true) 如果我再次点击 ImageButton 设置 Polyline.visible(false)

thanks in advance!!!提前致谢!!!

I use this code to my Zoom Buttons but i do not know how configure them to change visibility on polylines...我将此代码用于我的缩放按钮,但我不知道如何配置它们以更改多段线上的可见性...

public class TransBus extends AppCompatActivity implements OnMapReadyCallback {

ImageButton busBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_trans_bus);

    //Hooks
    busBtn = findViewById(R.id.bus1);

     busBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) { visibilityOn(); }
    });

    SupportMapFragment supportMapFragment = SupportMapFragment.newInstance();
    getSupportFragmentManager().beginTransaction().add(R.id.container, supportMapFragment).commit();
    supportMapFragment.getMapAsync(this);

}

public void visibilityOn() {?
    
}

You can use the setVisibility() method of polylineOptions defined in the android sdk .您可以使用android sdk中定义的 polylineOptions 的 setVisibility() 方法。

You can change the visibility by calling this code on the polyline object您可以通过在折线 object 上调用此代码来更改可见性

 polyline.setVisibility(false)

if you want to check out other methods you can check the documentation如果您想查看其他方法,可以查看文档

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

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