Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : add numbers to map markers

I'm working on a map that has multiple markers on it. These markers use a custom icon.

Is there a way to add numbers to these icons ?

edit: here is an example of what I want to do

enter image description here

I want to generate these icons programmatically and add them to the map.

Thanks

like image 235
Nabil Echaouch Avatar asked Feb 04 '15 00:02

Nabil Echaouch


1 Answers

first, you can use library.

or, you should implement custom icons into drawable folder and put code below.

MarkerOptions markeropt = new MarkerOptions(); markeropt.snippet("Snippet"); markeropt.icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_icon));

this solution would be helpful! here is a link's snippet.

Bitmap.Config conf = Bitmap.Config.ARGB_8888; 
Bitmap bmp = Bitmap.createBitmap(200, 50, conf); 
Canvas canvas = new Canvas(bmp);

canvas.drawText("TEXT", 0, 50, paint); // paint defines the text color, stroke width, size
mMap.addMarker(new MarkerOptions()
                                .position(clickedPosition)
                                //.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker2))
                                .icon(BitmapDescriptorFactory.fromBitmap(bmp))
                                .anchor(0.5f, 1)
                                    );
like image 183
iroiroys Avatar answered Nov 06 '22 09:11

iroiroys