2014-07-18 60 views
0

我正在使用自定義圖像作爲標記在Google地圖項目中的標記。但是,該標識顯示爲矩形圖像。但我希望它是彎曲的在底部。有沒有辦法讓它彎曲。在谷歌地圖中製作自定義標記,像在地圖上一樣彎曲在底部

我使用的標記的代碼如下所示:

public class retrieveimage extends AsyncTask<String,Void,Void> 
{ 
Store_data s; 
MarkerOptions marker; 
Bitmap pinbit; 
    public retrieveimage(Store_data s) { 
     this.s=s; 
    } 
    @Override 
    protected Void doInBackground(String... arg0) { 
     try { 
      marker = new MarkerOptions().position(new LatLng(Double.parseDouble(s.store_latitude),Double.parseDouble(s.store_longitude))).title(s.store_name); 
      String url1=arg0[0]; 
      URL url = new URL(url1); 
      HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 
      connection.setDoInput(true); 
      connection.connect(); 
      InputStream input = connection.getInputStream(); 
      bitmap= BitmapFactory.decodeStream(input); 
      pinbit=bitmap; 



     } catch (IOException e) { 
      e.printStackTrace(); 
      return null; 
     } 
     return null; 

    } 
    @Override 
    protected void onPostExecute(Void result) { 
     pinbit=Bitmap.createScaledBitmap(pinbit,75,56,false); 
     marker.icon(BitmapDescriptorFactory.fromBitmap(pinbit)); 
     // adding marker 

     googleMap.addMarker(marker); 
    } 

} 

回答

0

可以嘗試這個彎曲圖像。

enter image description here

0

首先,你可以使用圖標谷歌地圖標記與transpanent部分,somethink這樣enter image description here如果它不能幫助你,嘗試從代碼使四捨五入的圖像:

public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) { 
    Bitmap sbmp; 
    if (bmp.getWidth() != radius || bmp.getHeight() != radius) 
     sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false); 
    else 
     sbmp = bmp; 
    Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), 
      sbmp.getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(output); 

    final int color = 0xffa19774; 
    final Paint paint = new Paint(); 
    final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight()); 

    paint.setAntiAlias(true); 
    paint.setFilterBitmap(true); 
    paint.setDither(true); 
    canvas.drawARGB(0, 0, 0, 0); 
    paint.setColor(Color.parseColor("#BAB399")); 
    canvas.drawCircle(sbmp.getWidth()/2 + 0.7f, sbmp.getHeight()/2 + 0.7f, 
      sbmp.getWidth()/2 + 0.1f, paint); 
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); 
    canvas.drawBitmap(sbmp, rect, rect, paint); 


    return output; 
} 
+0

PorteDuff類未找到錯誤! – user3849303

+0

我得到它的工作。但它不給我在我想要的底部的針。 – user3849303

+0

你能解釋一下你想要更多細節嗎?我會盡力幫助你 –