moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 335 forks source link

How to draw path on TileView #498

Closed Amattia closed 5 years ago

Amattia commented 5 years ago

Hi, I would need to implement a function that create paths on the TileView dynamically, I looked for guides, or examples but refer to the old documentation, could you kindly give me an example on how to achieve what was required? (I use the 2.2.9 version of the library)

Specifically: given a set of points (coordinates of points on the screen) I should create a path on the TileView.

Actually I have tried this code but not work

        ArrayList<double[]> points = new ArrayList<>();
        points.add(new double[]{42.379676, -71.094919});
        points.add(new double[]{42.370000, -71.094919});
        points.add(new double[]{42.370000, -71.080000});
        points.add(new double[]{42.379676, -71.080000});

        Paint paint = tileView.getDefaultPathPaint();
        paint.setShadowLayer(4, 2, 2, 0x66000000);
        paint.setPathEffect(new CornerPathEffect(5));
        tileView.drawPath(points, paint);
moagrius commented 5 years ago

the demo shows an example of drawing paths using the new plugin system. that code specifically starts on this line, https://github.com/moagrius/TileView/blob/master/demo/src/main/java/tileview/demo/TileViewDemoAdvanced.java#L105, but you should read the whole file so you can understand how to use plugins, etc