android - Android 上的 Mapbox 无法添加源异常
问题描述
当我尝试将源添加到 Android 上的 Mapbox 地图时出现异常,即使我之前删除了每个同名的源。
我试图删除源然后层或层然后源并且没有任何效果。
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:源 floor_map_source 已存在。floor_map_source 是 SOURCE 的值。
解决方案
我发现了问题,实际上,我使用的 layerName 是不同的,并且阻止了源删除。在设置新图层之前,我必须添加旧图层的名称并将其删除。
推荐阅读
- java - 通过 gmail 附件查看 HTML 文件
- cypress - 如何在 cypress 中为 oauth2 google 登录执行 e2e 测试?
- javascript - 获取动态添加选项的选项值
- angular - 如何在 Spring Boot 中通过 Rest API 下载文件?
- dhtmlx - 如何在 DHTMLX 甘特图的自动计划中处理任务级日历
- verilog - 16 位 CLA 实例化
- php - Laravel Edit 表单首次加载时显示空白屏幕
- load-balancing - Grafana 无法与负载均衡器一起正常工作
- node.js - 弹性搜索中的条件排序
- reactjs - React Material UI - 为什么 CSS 类在使用 withStyles 时会重复?