gpt4 book ai didi

android - Android 上的 Mapbox 无法添加源异常

转载 作者:行者123 更新时间:2023-12-04 15:50:13 24 4
gpt4 key购买 nike

当我尝试将源添加到 Android 上的 Mapbox map 时出现异常,即使我之前删除了每个同名的源。

我试图删除源然后层或层然后源并且没有任何效果。

    if (map != null){
String layerName = floor.getLayerName();

map.removeLayer(layerName);
//Remove source and layer if already selected
map.removeSource(SOURCE); //SOURCE IS A CONST
map.clear();

String url = GEOSERVER_URL_NAME;
RasterSource resource = new RasterSource(SOURCE,new TileSet("tileset",url+layerName));
map.addSource(resource);
RasterLayer webMapLayer = new RasterLayer(layerName,SOURCE);
map.addLayerBelow(webMapLayer, "com.mapbox.annotations.points");
poisViewModel.refreshPoisByName(building.getId(), floor.getId(), "");
}

我正进入(状态:

com.mapbox.mapboxsdk.style.sources.CannotAddSourceException: Source floor_map_source already exists. floor_map_source is the value of SOURCE.

最佳答案

我发现了问题,实际上,我使用的 layerName 是不同的,并且阻止了源删除。
在设置新图层之前,我必须添加旧图层的名称并将其删除。

关于android - Android 上的 Mapbox 无法添加源异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54133129/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com