Android + universal image downloader: show custom marker with image on google map

I am working on an application that has a google map. The default marker on the map is visible, but I need to take a picture from the facebook url and then show it on the google map. I am using "universal-image-loader-sample-1.8.6.apk" to download images using the url.

Now, to upload an image, I am doing this.

ImageLoader imageLoader;
imageLoader = ImageLoader.getInstance();
ImageLoaderConfiguration ilc = ImageLoaderConfiguration.createDefault(this);
imageLoader.init(ilc);
ImageView imageView = (ImageView)findViewById(R.id.friend_pic);
imageLoader.displayImage(stringImageUrl, imageView);

The simple displayImage () code takes two arguments: first stringImageUrl (page URL), second imageView (ImageView in layout).

Now why do I need a ViewImage object if I need to show an image on a map. The Well ImageLoader object does not return a bitmap from any of its functions before I used ImageView to set the extracted image from the url to imageview, and then get the image in Bitmap.
What I did is something like this.

Drawable drawble = imageView.getDrawable();
BitmapDescriptor icon=BitmapDescriptorFactory.fromBitmap(((BitmapDrawable)drawble).getBitmap());

Once I received the image in BitmapDescriptor, it is easy to set it in the marker.

Marker location = googleMap.addMarker(new MarkerOptions().visible(true)
                .title(stringName).position(position).icon(icon);

but the problem is THAT DOES NOT WORK. The kernel appears in the imageView , but cannot get it in the Marker .

+4
2

, : Android-.

jar : http://code.google.com/p/android-query/downloads/list

AQuery androidAQuery=new AQuery(this);

:

androidAQuery.id(YOUR IMAGEVIEW).image(YOUR IMAGE TO LOAD, true, true, getDeviceWidth(), ANY DEFAULT IMAGE YOU WANT TO SHOW);

, URL-. Bitmap URL:

androidAQuery.ajax(YOUR IMAGE URL,Bitmap.class,0,new AjaxCallback<Bitmap>(){
                        @Override
                        public void callback(String url, Bitmap object, AjaxStatus status) {
                            super.callback(url, object, status);

                            //You will get Bitmap from object.
                        }

                    });

, , ; , ; .

+1

, , .

1. AndroidQuery

2. " " → " ".

3. :

AQuery androidQuery = new AQuery(this);

androidQuery.ajax(url.trim(), Bitmap.class, 0, new AjaxCallback<Bitmap>() {
     @Override
     public void callback(String url, Bitmap object, AjaxStatus status) {
         super.callback(url, object, status);
         googleMap.addMarker(new MarkerOptions().title("yourtitle").icon(BitmapDescriptorFactory.fromBitmap(object)).position(new LatLng(yourlatitude), Double.parseDouble(yourlongitude))));
     }
});
0

All Articles