Draw GoogleMap path with 9patch

I am currently trying to draw a fairly stylized path on a map.

Way how is he

public ArrayList<Polyline> renderNeonPolyline(Context context,
                                                           ArrayList<LatLng> routeCoordinates,
                                                           GoogleMap googleMap) {
    ArrayList<Polyline> polylines = new ArrayList<>();
    for (int i = 0; i < 6; i++) {
        PolylineOptions polylineOptions = new PolylineOptions();
        polylineOptions.width(48 - (i * 8));
        if (i == 0) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.apple_25));
        } else if (i == 1) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.apple_50));
        } else if (i == 2) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.apple_75));
        } else if (i == 3) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.apple));
        } else if (i == 4) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.white_75));
        } else if (i == 5) {
            polylineOptions.color(ContextCompat.getColor(context, R.color.white));
        }
        polylineOptions.addAll(routeCoordinates);
        Polyline polyline = googleMap.addPolyline(polylineOptions);
        polylines.add(polyline);
    }

    return polylines;
}

So it works. He draws a beautiful line with a neon look of effect ... most of the time. For some reason, there are certain circumstances in which only the first row of apple_25 is obtained. (I think this is due to the fact that we are trying to simultaneously scale and pan the map, but did not study it). In addition, the ends look rather rude.

What I really hoped to do was draw a single line with a 9patch image.

Any ideas?

thank

+4
source share
1 answer

, , .

richmaps ( ) :

RichPolylineOptions polylineOpts = new RichPolylineOptions(null)
        .zIndex(3)
        .strokeWidth(35)
        .add(new RichPoint(new LatLng(40.22987, -3.95931)))
        .add(new RichPoint(new LatLng(40.23109, -3.95926)))
        .add(new RichPoint(new LatLng(40.23063, -3.95837)))
        .add(new RichPoint(new LatLng(40.23169, -3.95809)))
        .add(new RichPoint(new LatLng(40.23093, -3.95705)))
        .add(new RichPoint(new LatLng(40.23023, -3.95626)))
        .strokeShader(new BitmapShader(
                BitmapFactory.decodeResource(getResources(), R.drawable.yourdrawable),
                Shader.TileMode.REPEAT,
                Shader.TileMode.REPEAT)); // Using a Bitmap as the stroke shader
RichPolyline polyline = polylineOpts.build();
polyline.add(new RichPoint(new LatLng(40.23163, -3.95602)).color(Color.CYAN)); // RichPoint added after the creation of the RichPolyline
richLayer.addShape(polyline);

mMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(40.23063, -3.95837), 18, 0, 0)));

:

enter image description here

+3

All Articles