mapbox 移除底图图层

mapbox remove basemap layer

我正在开发 mapbox android SDK。 我可以显示我们的地图图块(png 栅格图块),但有些地区是透明的,在那些地方会出现 mapbox 地图。 在另一个与 google 地图相同的项目中,我已经完成了这个并且 google 有一个名称为的选项:

googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);

删除默认的 google 地图并只显示我的图块,但在 mapbox android 中没有这样的选项,我很惊讶这个巨大的 sdk 没有这个基本的选项或我无法轻松找到。 有没有人可以帮我解决这个问题?

很高兴地说,我已经从 mapbox 中删除了所有图层、源和注释,然后添加了我们自己的栅格图块集:

 for (int i = 0; i < mapboxMap.getLayers().size(); i++) {
        mapboxMap.removeLayer(mapboxMap.getLayers().get(i));
    }

    for (int i = 0; i < mapboxMap.getSources().size(); i++) {
        mapboxMap.removeSource(mapboxMap.getSources().get(i));
    }

    for (int i = 0; i < mapboxMap.getAnnotations().size(); i++) {
        mapboxMap.removeAnnotation(mapboxMap.getAnnotations().get(i));
    }



webMapSource = new RasterSource(
            "web-map-source",
            new TileSet("tileset", "ourownwebsite.com?" +
                    "bbox={bbox-epsg-3857}" +
                    "&service=WMS" +
                    "&version=1.1.0" +
                    "&EXCEPTIONS=application/vnd.ogc.se_inimage" +
                    "&request=GetMap" +
                    "&layers=test:GSLD256" +
                    "&width=256" +
                    "&height=256" +
                    "&srs=EPSG:3857" +
                    "&format=image/png"), 256);

    mapboxMap.addSource(webMapSource);         
    // Add the web map source to the map.
    RasterLayer webMapLayer = new RasterLayer("web-map-layer", "web-map-source");
    mapboxMap.addLayer(webMapLayer);

您可以使用 mapboxMap.removeAnnotations()mapboxMap.clear() 从地图中删除所有注释。

至于基础图层,最接近GoogleMap.MAP_TYPE_NONE的是设置一个仅包含背景图层的样式。为此,使用包含类似于此的样式定义的字符串调用 mapboxMap.setStyleJson

{
  "version": 8,
  "name": "Empty",
  "sources": {
  },
  "layers": [
    {
      "id": "background",
      "type": "background",
      "paint": {
        "background-color": "hsl(47, 26%, 88%)"
      }
    }
  ],
  "id": "empty"
}