jacob-g / cleveland-rta-next-bus-train

Cleveland Transit Mobile Application
0 stars 0 forks source link

Label line paths #81

Closed jacob-g closed 7 years ago

jacob-g commented 7 years ago

Code like this can be used to put text directly on the map:

Bitmap.Config conf = Bitmap.Config.ARGB_8888;
                        Bitmap bmp = Bitmap.createBitmap(200, 16 * (transferStrings.size() + 2), conf);
                        Canvas canvas = new Canvas(bmp);

                        Paint paint = new Paint();
                        paint.setColor(Color.BLACK);
                        paint.setStrokeWidth(1);
                        paint.setTextSize(16);

                        canvas.drawText("Transfer to:", 0, 16, paint);
                        int i = 2;
                        for (String s : transferStrings) {
                            canvas.drawText(s, 0, 16 * i, paint); // paint defines the text color, stroke width, size
                            i++;
                        }
                        mMap.addMarker(new MarkerOptions()
                                .position(pos)
                                //.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker2))
                                .icon(BitmapDescriptorFactory.fromBitmap(bmp))
                                .anchor(0.5f, 1)
                        );