映射框图层minzoom / maxzoom有时不起作用

时间:2019-06-27 08:50:23

标签: android mapbox mapbox-android

我有3层 -一个用于聚集点(L1) -一个使未聚类的点显示为聚类(L3) -一个用于隐藏点(L2)

我已设置图层的最小缩放级别和最大缩放级别,以便: -当变焦> 9(远)时,仅出现L1和L3 -变焦<9(近)时,仅显示L2

对于L1和L2都可以正常工作,并可以缩放缩放级别。 取而代之的是,图层L3总是出现在地图中。

            GeoJsonSource source = new GeoJsonSource(
                    "sourcePoiItems",
                    featureCollection,
                    new GeoJsonOptions()
                            .withCluster(true)
                            .withClusterMaxZoom(8)
                            .withClusterRadius(15)
                            .withMinZoom(0)
                            .withMaxZoom(9)
                            .withTolerance(10));
            GeoJsonSource source2 = new GeoJsonSource(
                    "sourcePoiItems2",
                    featureCollection,
                    new GeoJsonOptions()
                            .withCluster(false)
                            .withMinZoom(9)
                            .withMaxZoom(16));
            GeoJsonSource source3 = new GeoJsonSource(
                    "sourcePoiItems3",
                    featureCollection,
                    new GeoJsonOptions()
                            .withCluster(true)
                            .withClusterMaxZoom(8)
                            .withClusterRadius(10)
                            .withMinZoom(0)
                            .withMaxZoom(9)
                            .withTolerance(10));
            mapboxMap.getStyle().addSource(source);
            mapboxMap.getStyle().addSource(source2);
            mapboxMap.getStyle().addSource(source3);
            SymbolLayer unclustered = new SymbolLayer("unclustered-points", "sourcePoiItems2");
            unclustered.setProperties(
                    PropertyFactory.iconImage(get("icon")));
            mapboxMap.getStyle().addLayer(unclustered);

            //relevant part

            CircleLayer circles = new CircleLayer("cluster-3", "sourcePoiItems3");
            circles.setProperties(
                    PropertyFactory.circleColor(layers[0][1]),
                    PropertyFactory.circleRadius(18f)
            );
            circles.setFilter(
                    not(has("point_count"))
            );
            mapboxMap.getStyle().addLayer(circles);

            SymbolLayer count1 = new SymbolLayer("count1", "sourcePoiItems3");
            count1.setProperties(
                    PropertyFactory.textField(Expression.literal("1")),
                    PropertyFactory.textSize(12f),
                    PropertyFactory.textColor(Color.WHITE),
                    PropertyFactory.textIgnorePlacement(true),
                    PropertyFactory.textAllowOverlap(true)
            );
            count1.setFilter(Expression.not(Expression.has("point_count")));
            mapboxMap.getStyle().addLayer(count1);

1 个答案:

答案 0 :(得分:0)

您能为看到的内容制作一个有效的测试用例吗?