在其他符号上方显示LocationComponent

时间:2019-08-06 09:27:48

标签: android mapbox mapbox-android

我尝试将当前位置指示器放在地图上的所有其他位置之上。

我被派去研究“ layerAbove”,但我没有图层,只是使用通过符号管理器生成的图标进行样式设置。

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
      super.onViewCreated(view, savedInstanceState)
    // ...
    mapView.getMapAsync { mapboxMap ->

        //...
        mapboxMap.setStyle(getStyleBuilder(MAPBOX_STYLE)) { style ->
            val locationComponent = mapboxMap.locationComponent
            context?.let { context ->

                locationComponent.activateLocationComponent(context,style)
            }
            locationComponent.isLocationComponentEnabled = true
            val image: String = IMAGE_CONST
            val symbolManager = SymbolManager(mapView, mapboxMap, style)
            val symbolOptions = SymbolOptions()
                   .withLatLng(LatLng(myItem.latitude, myItem.longitude))
                   .withIconImage(image)
                   .withIconSize(1.1f)
                   .withZIndex(0)
            symbolManager.create(symbolOptions)            }

    }
}

private fun getStyleBuilder(styleUrl: String): Style.Builder {
    var builder = Style.Builder().fromUrl(styleUrl)
    builder = withImage(R.drawable.icon, IMAGE_CONST, builder)
    //...
    return builder

}

private fun withImage(image: Int, imageKey: String, builder: Style.Builder): Style.Builder {
    val generateBitmap = generateBitmap(image)
    return generateBitmap?.let {
        builder.withImage(imageKey, it)
    } ?: builder
}`

结果是,添加的符号放置在locationComponent的上方,而不是它的下方。

0 个答案:

没有答案