【问题标题】:How to hide layer in mapbox android?如何在mapbox android中隐藏图层?
【发布时间】:2020-01-05 18:32:14
【问题描述】:
   private void AddSanciangkoStreet(@NonNull Style style) {

   style.addImage("sanciangko-street",
                   BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.floodicon)));

            style.addSource(new GeoJsonSource("sanciangkoFlood1-source-id"));

            style.addLayer(new SymbolLayer("sanciangkoFlood1-layer-id", "sanciangkoFlood1-source-id").withProperties(
                    iconImage("sanciangko-street"),
                    iconIgnorePlacement(true),
                    iconAllowOverlap(true),
                    iconSize(1f)
            ));

我需要在我的 statusValue = 0 时隐藏此符号,并在 statusValue = 1 时再次出现。请帮助

【问题讨论】:

    标签: android mapbox mapbox-android mapbox-marker


    【解决方案1】:

    将可见性属性更改为NONE/VISIBLE:

    public void updateLayer(final int statusValue) {
        mapboxMap.getStyle(new Style.OnStyleLoaded() {
            @Override
            public void onStyleLoaded(@NonNull Style style) {
                Layer layer = style.getLayer("sanciangkoFlood1-layer-id");
                if (layer != null) {
                    layer.setProperties(PropertyFactory.visibility(
                            statusValue == 0 ? Property.NONE : Property.VISIBLE
                    ));
                }
            }
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-12
      • 2020-03-08
      • 2022-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多