我正在尝试使用新的有前景的GL Symbol图层/源在MapBox上移动汽车。在android和ios上看起来都很好,但是我面临着两个不可能。
如何完全禁用符号聚类?
更新:代码甚至快速的解决方案! (可能是错误?请参见withTextField上的评论)
in onStyleLoaded():
...
carManager = new SymbolManager(mapView, mapboxMap, style);
carManager.setIconAllowOverlap(true);//doesn't help
carManager.setIconIgnorePlacement(true);//doesn't help
...
in drawCarFunction():
...
SymbolOptions carOptions = new SymbolOptions()
.withLatLng(latLng)
.withIconImage(carPlate)
//.withTextField(carPlate) //!!!! here it will cluster if text exists, and will NOT - without any text
;
Symbol car= carManager.create(carOptions);
carSymbols.add(car);
...
下一个问题:
如何快速使符号单击更简单?
如何在符号中存储我自己的UID?
更新:代码。注意getTag()附近的评论
void moveExistingCarOrAddNew(int carId, LatLng newLocation){
for (int i = 0; i < carManager.getAnnotations().size(); i++) {
if (carManager.getAnnotations().get(i).getTag()==carId){ //but no getTag() here, I should fit data into text fields
car.setLatLng(newLocation); //move!
} else {
...//create new marker as shown above }
}
}
}