android - Create multicolor line in Mapbox -


i using mapbox in project , ran need draw multicolor line throught map. used many linelayer's. when line have small lenght, after zoom disappear. can say, how can fix this? or suggest less crutch variant?

    private fun updatesegment(index: int, colorid: double, beginpoint: point, endpoint: point) {     val coordinates = mutablelistof<position>()     val beginlatitude = beginpoint.latitude     val beginlongitude = beginpoint.longitude     val endlatitude = endpoint.latitude     val endlongitude = endpoint.longitude      if (beginlatitude != null && beginlongitude != null         && endlatitude != null && endlongitude != null) {          coordinates.add(position.fromcoordinates(beginlongitude, beginlatitude))         coordinates.add(position.fromcoordinates(endlongitude, endlatitude))          val linestring = linestring.fromcoordinates(coordinates);          val featurecollection =             featurecollection.fromfeatures(arrayof(feature.fromgeometry(linestring)))          val sourceid = "line-source_$index"         val layerid = "line-layer_$index"          val geojsonsource = geojsonsource(sourceid, featurecollection);          if (mapboxmap?.getlayer(layerid) != null) {             mapboxmap?.removelayer(layerid)         }         if (mapboxmap?.getsource(sourceid) != null) {             mapboxmap?.removesource(sourceid)         }         mapboxmap?.addsource(geojsonsource);          val linelayer = linelayer(layerid, sourceid)          val color = when (colorid) {             0.0 -> contextcompat.getcolor(context, r.color.color0)             1.0 -> contextcompat.getcolor(context, r.color.color1)             2.0 -> contextcompat.getcolor(context, r.color.color2)         }          linelayer.setproperties(             propertyfactory.linecap(property.line_cap_round),             propertyfactory.linejoin(property.line_join_round),             propertyfactory.linewidth(5f),             propertyfactory.linecolor(color)         )          mapboxmap?.addlayer(linelayer)     } } 


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -