Android creating BitmapDescriptor exception

前端 未结 4 1643
孤街浪徒
孤街浪徒 2021-01-06 03:01

I\'m writing an application that works alot with google map and markers on it. My task is to create and display some amount of markers on google map. Markers have custom ima

4条回答
  •  走了就别回头了
    2021-01-06 03:28

    Use Picasso , Glide or Fresco Literary to cache bitmaps efficiently.

     Picasso.with(getContext())
       .load(R.drawable.marker)
       .resize(width, width)
        .into(new Target() {
       @Override
      public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
       markerOptionsHome = new MarkerOptions();
       markerOptionsHome.title("Home location");
       markerOptionsHome.snippet("");
       markerOptionsHome.position(latlng);
       markerOptionsHome.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
       homeLocationMarker = map.addMarker(markerOptionsHome);
    
                }
    
        @Override
       public void onBitmapFailed(Drawable errorDrawable) { }
         @Override
        public void onPrepareLoad(Drawable placeHolderDrawable) {  }
              });
    

提交回复
热议问题