Google Map Cluster with Url

mdtuyen

我使用Google的Android-map-utils库处理Google Map集群。就我而言,我使用Glide从URL加载图像:

@Override
        protected void onBeforeClusterItemRendered(final FeedsModel feedsModel, final MarkerOptions markerOptions) {
            // Draw a single person.
            // Set the info window to show their name.
            Glide
                    .with(mActivity.getApplicationContext())
                    .load(feedsModel.getImages().getThumbnail().getUrl())
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                            mImageView.setImageDrawable(resource);
                            Bitmap icon = mIconGenerator.makeIcon();
                            Marker markerToChange = null;
                            for (Marker marker : mClusterManager.getMarkerCollection().getMarkers()) {
                                if (marker.getPosition().equals(feedsModel.getPosition())) {
                                    markerToChange = marker;
                                }
                            }
                            // if found - change icon
                            if (markerToChange != null) {
                                markerToChange.setIcon(BitmapDescriptorFactory.fromBitmap(icon));
                            }
                        }
                    });
            Bitmap icon = mIconGenerator.makeIcon();
            markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
        }

        @Override
        protected void onBeforeClusterRendered(final Cluster<FeedsModel> cluster, final MarkerOptions markerOptions) {
            // Draw multiple people.
            // Note: this method runs on the UI thread. Don't spend too much time in here (like in this example).
            final List<Drawable> profilePhotos = new ArrayList<Drawable>(Math.min(4, cluster.getSize()));
            final int width = mDimension;
            final int height = mDimension;

            int i = 0;

            for (final FeedsModel p : cluster.getItems()) {
                // Draw 4 at most.
                i++;
                Glide
                        .with(mActivity.getApplicationContext())
                        .load(p.getImages().getThumbnail().getUrl())
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(new SimpleTarget<GlideDrawable>() {
                            @Override
                            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                                resource.setBounds(0, 0, width, height);
                                profilePhotos.add(resource);
                                MultiDrawable multiDrawable = new MultiDrawable(profilePhotos);
                                multiDrawable.setBounds(0, 0, width, height);

                                mClusterImageView.setImageDrawable(multiDrawable);
                                Bitmap icon = mClusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
                                markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
                            }
                        });

                if (i == 4) break;
            }
            Bitmap icon = mClusterIconGenerator.makeIcon(String.valueOf(cluster.getSize()));
            markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
        }

通过上面的代码,我看到:放大或缩小时,“项目”和“群集”中的图像加载错误。我这是怎么了?

mdtuyen

最后,我找到了解决方案,并结合了:

protected void onClusterItemRendered(FeedsModel clusterItem, Marker marker) 
protected void onClusterRendered(Cluster<FeedsModel> cluster, Marker marker)

这些功能可以从URL加载图像

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

动态更新Cluster Google Map的mcOptions选项

来自分类Dev

Google Map与Cluster Manager:不建议使用onCameraChangeListener

来自分类Dev

Android Google Map Cluster图标忽略自定义图标

来自分类Dev

使用Google Map utils中的Map Cluster按下标记后,在InfoWindow中自定义信息

来自分类Dev

隐藏侧面板是否有Google Map URL参数?

来自分类Dev

Google Map API密钥错误“您的网站URL得到授权”

来自分类Dev

在WebView中打开Google Map URL有问题吗?

来自分类Dev

无法通过Angular.js加载Google Map URL

来自分类Dev

具有动态图像URL的Android Google Map群集项标记-使用所有标记覆盖URL

来自分类Dev

URL的@PathVariable Map语法?

来自分类Dev

偏心显示Google Map

来自分类Dev

Google Map API错误

来自分类Dev

Google Map Maker API?

来自分类Dev

Google Map错误:InvalidKeyOrUnauthorizedURLMapError

来自分类Dev

Google Map Fragment padding

来自分类Dev

tableView中的Google Map

来自分类Dev

Google Map中的警告

来自分类Dev

Google Map Geolocation错误

来自分类Dev

Android Google Map崩溃

来自分类Dev

Google Map响应

来自分类Dev

Google Map Options Android

来自分类Dev

Google Map主题样式

来自分类Dev

Google Map Clusterer

来自分类Dev

如何在Google Map URL API密钥字符串中添加要从Conf文件读取的变量

来自分类Dev

与Google Map的map.getBounds()等效的Openlayer

来自分类Dev

Google Map Referer-not-allowed-map-error

来自分类Dev

使用Google Map v2无法显示Google Map

来自分类Dev

显示Google Map onclick事件-Google Map API

来自分类Dev

使用Google Map v2无法显示Google Map