谷歌地图集群项目标记图标与毕加索

时间:2015-04-29 14:44:49

标签: android google-maps android-maps-utils

我使用Google Map SDK 7.3.0和android-maps-utils 0.3.4,因为我需要在地图上为我的标记集群。

My map

好的,问题是,我不应该有红色标记。只有绿色+蓝色标记。 我将DefaultClusterRenderer子类化为创建我的自定义标记视图,但有时它不起作用。

我使用毕加索来获取绿色图标,因为它来自API。但问题是,当毕加索加载位图时为时已晚,图标已经设置为默认值(红色)。

这是我的onBeforeClusterItemRenderer:

            Picasso.with(getApplicationContext()).load(item.url).into(new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                FrameLayout icon = (FrameLayout) LayoutInflater.from(getApplicationContext()).inflate(R.layout.marker, null);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    icon.findViewById(R.id.bg).setBackground(new BitmapDrawable(getResources(), bitmap));
                } else {
                    icon.findViewById(R.id.bg).setBackgroundDrawable(new BitmapDrawable(getResources(), bitmap));
                }


                Bitmap b = createDrawableFromView(Home.this, icon);

                if (marker != null) {
                    marker.icon(BitmapDescriptorFactory.fromBitmap(b));
                }
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {

            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {

            }
        });

0 个答案:

没有答案