微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

GoogleMap片段上的多个PolylineOptions

如何解决GoogleMap片段上的多个PolylineOptions

我正在尝试在地图中插入更多折线选项,我想放置3个条件,然后根据它们选择线条的颜色。 有了代码,我可以看到正确的地图部分,但没有显示任何行。 有人知道如何帮助我吗?

override fun onMapReady(p0: GoogleMap?) {
    googleMap = p0
    val bc = LatLngBounds.Builder()

    val points: ArrayList<LatLng> = ArrayList()
    val locations: ArrayList<Location> = ArrayList()

    val polypoint : ArrayList<polylineoptions> = ArrayList()


    googleMap!!.setonMapLoadedCallback {
        foo.bar.forEachIndexed {fooIndex,step ->
            bar.asd.forEachIndexed { index,location ->
                asd.add(location)
                for (point: Location in asd) {

                    val list = foo.bar[fooIndex]!!.asd.chunked(2)

                    if (index < list.size) {

                        val value = getValue()

                        if (value >= 0 && value < 70) {
                            googleMap!!.addpolyline(polylineoptions()
                                    .add(LatLng(point.latitude,point.longitude),LatLng(point.latitude,point.longitude))
                                    .width(14f)
                                    .color(Color.GREEN))
                        } else if (value >= 70 && value < 150) {
                            googleMap!!.addpolyline(polylineoptions()
                                    .add(LatLng(point.latitude,point.longitude))
                                    .width(14f)
                                    .color(Color.YELLOW))
                        } else {
                            googleMap!!.addpolyline(polylineoptions()
                                    .add(LatLng(point.latitude,point.longitude))
                                    .width(14f)
                                    .color(Color.RED))
                        }
                    }
                }

                points.add(LatLng(location.latitude,location.longitude))
                bc.include(LatLng(location.latitude,location.longitude))
            }
        }



        if (points.size != 0) {
            if (points.size < 2) {
                bc.include(points[0])
                bc.include(points[points.size - 1])
            }
            googleMap!!.moveCamera(CameraUpdateFactory.newLatLngBounds(bc.build(),60))
        }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。