(Android) Can I change the shape of a polyline on Google maps?

I know that we can change the color of the polyline using "polylineOptions.color (YOUR_COLOR)"; bit can you set the form on it? (I would like for me to have a blue frame and be white inside, if the route should be completed, and if it is completed, set the color to blue - no more than the border)

This is what I have so far, I call this function 2 times, once for the completed path, and then for the path to be completed:

  public void createProgressRouteOnMap( ArrayList<LatLng> route, boolean done){
    if(done) {
        if(polyline != null){
            polyline.remove();
        }
    }else{
        if(polyline2 != null){
            polyline2.remove();
        }
    }
    PolylineOptions polyLineOptions = new PolylineOptions();
    polyLineOptions.addAll(route);
    polyLineOptions.width(10);
    if(done){
        polyLineOptions.color(getResources().getColor(R.color.background));
    }else{
        polyLineOptions.color(getResources().getColor(R.color.blue_route));
    }
    if(mMap == null){
        setUpMapIfNeeded();
    }
    if(done) {
        polyline = mMap.addPolyline(polyLineOptions);
    }else{
        polyline2 = mMap.addPolyline(polyLineOptions);
    }

}
+4
source share
1 answer

Will it do it?

 GoogleMap map;
 // Add a thick blue line
 Polyline line = map.addPolyline(new PolylineOptions()
     .add(new LatLng1, new LatLng2)
     .width(10)
     .color(Color.BLUE));
 // Add a thin white line
 Polyline line = map.addPolyline(new PolylineOptions()
     .add(new LatLng1, new LatLng2)
     .width(4)
     .color(Color.WHITE));
+9
source

Source: https://habr.com/ru/post/1546997/


All Articles