2011-02-16 1 views
0

Disons que j'ai obtenu le chemin absolu dans la photo. /mnt/sdcard/....jpgDéfinir la photo comme marqueur sur la carte

String path = "/mnt/sdcard/....jpg"; 
    BitmapDrawable d = new BitmapDrawable(this.getResources(), path); 
    d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); 

    overlayItem.setMarker(d); 

C'est ce que j'ai essayé, mais la photo ne s'affiche pas.

EDIT: fixe, mauvais chemin vers le fichier.

Répondre

1
Bitmap b = BitmapFactory.decodeFile(path); 

Ok, et que dire ceci:

Drawable d = Drawable.createFromPath(path); 
+0

Salut Pacha, setMarker() accepte uniquement le type Drawable. –

+0

Drawable.createFromPath (chemin); semble retourner null. –

+0

Peut-être, vous devriez essayer les méthodes: 'invalidateSelf()' ou 'setVisible (true, true)'. Kenyi, ce qui retourne les méthodes 'd.getIntrinsicWidth()' et 'd.getIntrinsicHeight()'? – Pasha

0

Pouvez-vous envoyer votre code? La façon dont Pacha a dit devrait fonctionner. Disons que vous avez une image en vous étirables dossier nommé your_image, vous pouvez le faire comme ceci:

 Point point = new Point(); 
     yourMapView.getProjection().toPixels(yourGeoPoint, point); 

     Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.your_image);    
     yourCanvas.drawBitmap(bmp, point.x, point.y-(your_size), null); 
Questions connexes