Mostrar marcador dentro de un recurso dibujable que obtenido de url

Mapa que muestra uers

Aquí está la página del mapa que tengo, que muestra todos los usuarios de mi aplicación. También las imágenes (marcadores) se obtienen de la URL dada desde mi servidor. Estos marcadores tienen que poner dentro de un dibujable (un círculo como la imagen como se muestra). Creé un círculo como el mapa de bits de la url usando lienzo.

public Drawable showMe(String url) { Bitmap bitmap=null; try { URL newurl = new URL(url); bitmap = BitmapFactory.decodeStream(newurl.openConnection().getInputStream()); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } bitmap=getBitmap(url); Paint paint = new Paint(); paint.setFilterBitmap(true); int targetWidth = 30; int targetHeight = 30; Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888); RectF rectf = new RectF(0, 0, 30, 30); Canvas canvas = new Canvas(targetBitmap); Path path = new Path(); path.addRoundRect(rectf, targetWidth, targetHeight, Path.Direction.CW); canvas.clipPath(path); canvas.drawBitmap( bitmap, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), new Rect(0, 0, targetWidth, targetHeight), paint); Matrix matrix = new Matrix(); matrix.postScale(1f, 1f); Bitmap resizedBitmap = Bitmap.createBitmap(targetBitmap, 0, 0, 30, 30, matrix, true); Bitmap bitmap_circle=mergeBitmaps(resizedBitmap); BitmapDrawable bd = new BitmapDrawable(bitmap_circle); return bd; } 

La función anterior creará el dibujable final para el marcador. También la función mergeBitmaps () fusionará tanto el recurso dibujable como el mapa de bits juntos.

 public Bitmap mergeBitmaps(Bitmap manBitmap){ try{ Bitmap markerBitmap = BitmapFactory.decodeResource( this.getResources(), R.drawable.circle_bg); Bitmap bmOverlay = Bitmap.createBitmap(markerBitmap.getWidth(), markerBitmap.getHeight(), markerBitmap.getConfig()); Canvas canvas = new Canvas(bmOverlay); Matrix matrix = new Matrix(); matrix.postScale(1f, 1f); canvas.drawBitmap(markerBitmap, matrix, null); canvas.drawBitmap(manBitmap, 5, 5, null); return bmOverlay; } catch(Exception ex){ ex.printStackTrace(); return null; } } 

Pero el problema es que este mapa de bits no es el mejor ajuste dentro del fondo Dibujable con el fin de obtener una sensación de que ambos juntos dará una sola imagen.

Alguien puede ayudarme ?

cambio

 canvas.drawBitmap(manBitmap, 5, 5, null); 

A smtg como

 canvas.drawBitmap(manBitmap, (markerBitmap.getWidth()-manbitmap.getWidth())/2, (markerBitmap.getHeight()-manbitmap.getHeight())/2, null); 
  • Giro a giro múltiples puntos ruta navegación Google Maps Intent en Android
  • La vista web de Android no muestra google maps
  • DefaultClusterRenderer getMarker () devuelve null cuando se hace zoom
  • IncompatibleClassChangeError inexplicado en la aplicación estable liberada causada por GoogleMaps
  • Compruebe si el marcador está dentro del radio del círculo
  • ¿Cómo abrir Google Maps con la dirección?
  • Abrir URL desde Marcador, Android Google Maps V2
  • Esta aplicación no se ejecutará a menos que actualice Google Play Services (a través de Bazaar)
  • ¿Consigue la distancia entre dos ubicaciones en android?
  • Google Maps Android API v2 bloquea el subproceso de la interfaz de usuario
  • Resultados de geocodificación sin mostrarlos en un mapa
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.