Rotate with the ability to rotate, which will be used as a marker icon in Google Map

I want to add markers to the map (api v2) from the currently selected one. I do it like this:

mMarkers.add(mMap.addMarker(new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromResource(R.drawable.pin)))); 

Now I want to rotate the drawing before using it as a marker icon. What is the best way to do this? I tried

 Bitmap bmpOriginal = BitmapFactory.decodeResource(this.getResources(), R.drawable.pin); Bitmap bmResult = Bitmap.createBitmap(bmpOriginal.getWidth(), bmpOriginal.getHeight(), Bitmap.Config.ARGB_8888); Canvas tempCanvas = new Canvas(bmResult); tempCanvas.rotate((float)answer.getPoints().get(i).getAzimut(), bmpOriginal.getWidth()/2, bmpOriginal.getHeight()/2); tempCanvas.drawBitmap(bmpOriginal, 0, 0, null); mMarkers.add(mMap.addMarker(new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(bmResult)))); 

But the result that can be extracted is strangely deformed. I think there should be a better and cleaner solution.

+4
source share

All Articles