我我使用谷歌mapV2和IM下载图像,从谷歌的地方API,并希望在弹出显示 [英] I my using google mapV2 and i m downloading image from google place api and want to display in the popup

查看:131
本文介绍了我我使用谷歌mapV2和IM下载图像,从谷歌的地方API,并希望在弹出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯使用的所有类的目标URL歌厅图像。

i m using all the classes for geting image through Url.

        ImageView imV=  ((ImageView) view.findViewById(R.id.badge));
        // Image url
        String image_url = "http://maps.gstatic.com/mapfiles/place_api/icons/cafe-71.png";
        final int stub_id = R.drawable.ic_action_search;
        // ImageLoader class instance
        ImageLoader imgLoader = new ImageLoader(getApplicationContext());

        // whenever you want to load an image from url
        // call DisplayImage function
        // url - image url to load
        // loader - loader image, will be displayed before getting image
        // image - ImageView
        imgLoader.DisplayImage(image_url,stub_id ,imV);

但它显示的默认图像,而不是URL下载图像。

but it is displaying the default image,rather than Url downloaded image.

<一个href="https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.InfoWindowAdapter" rel="nofollow">https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.InfoWindowAdapter

即时通讯使用infowindowAdapter类Goolge的和它说我cn't一旦数据与放大器时,改变形象;图像在窗口中加载,thts为什么它显示第一个默认的图像.....最迟不改变

i m using infowindowAdapter class of goolge and its says that i cn't change the image when once data & image is loaded in the window,thts why its displaying first default image..... and not changing later

那么,有没有其他办法? 在此先感谢

so is there any other way? thanks in advance

推荐答案

我有同样的问题。 我曾与一个AsyncTask的解决了这个问题。

I'm having the same problem. I've solved it with a asyncTask.

像这样

private Drawable _infoImageDrawable;
public class MyMapActivity extends MenuActivity
{
    .....code code code....

    protected void handleMarkerClicked(final Marker marker, final String url) {
        new AsyncTask<Void, Void, Void>()
        {   
            @Override
            protected void onPreExecute() 
            {
                super.onPreExecute();
                _infoImageDrawable = null;
            }

            @Override
            protected Void doInBackground(Void... params) 
            {
                InputStream is;
                try {
                     is = (InputStream) new URL(url).getContent();
                     _infoImageDrawable = Drawable.createFromStream(is, "");
                } catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                }
                return null;                
            }

            @Override
            protected void onPostExecute(Void result) 
            {
            super.onPostExecute(result);
            marker.showInfoWindow();
            }
        }.execute();
    }
}

然后,我刚才设置的绘制在InfoWindowAdapter第一个为空(删除旧的图像),并_imageInfoDrawable第二。 它的工作原理 - 。但我想一个更好的解决方案。

Then I just set the drawable in the InfoWindowAdapter to null first(remove old image) and to _imageInfoDrawable second. It works - but i would like a better solution.

这篇关于我我使用谷歌mapV2和IM下载图像,从谷歌的地方API,并希望在弹出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆