我正在尝试为 map 中用户的位置标记添加自定义图标。但图标显示为黑白。
LocationComponentOptions customLocationComponentOptions = LocationComponentOptions.builder(this)
.foregroundDrawable(R.drawable.android)
.build();
// Get an instance of the component
LocationComponent locationComponent = mapboxMap.getLocationComponent();
// Activate with options
locationComponent.activateLocationComponent(
LocationComponentActivationOptions.builder(this, loadedMapStyle)
.locationComponentOptions(customLocationComponentOptions)
.build());
// Enable to make component visible
locationComponent.setLocationComponentEnabled(true);
// Set the component's camera mode
locationComponent.setCameraMode(CameraMode.TRACKING);
// Set the component's render mode
locationComponent.setRenderMode(RenderMode.COMPASS);
我尝试了 this question 中选择的答案,但没有成功。我尝试使用 jpg 而不是 png,仍然没有任何变化。
如果我在实际设备上运行它,它工作得很好。所以我猜问题出在模拟器上。
最佳答案
正确,这只是模拟器的问题。查看此解决方法 - https://github.com/mapbox/mapbox-gl-native/issues/10829#issuecomment-441021598 .
关于android - 在 map 框中添加自定义位置图标 - 图像显示为黑白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57742123/