1

I am developing an Android application and have problem with downloading images to my map. In my application i am using Google Maps v2 and Aquery to download images. I want to show the related image when user clicks a marker on the map. This is the code snippet i am trying to achieve that functionality.

googleMap
                .setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
                    @Override
                    public void onInfoWindowClick(Marker marker) {
                        String allText = marker.getSnippet();
                        String[] bodyTextArray = allText.split("(;;)");
                        String bodyText = "";
                        String idText = "";
                        String imagePath = "";
                        if (bodyTextArray.length == 3) {
                            idText = bodyTextArray[0];
                            bodyText = bodyTextArray[1];
                            imagePath = bodyTextArray[2];

                        }
                        final View content2 = getActivity()
                                .getLayoutInflater().inflate(
                                        R.layout.map_marker, null);

                    AQuery aquery = new AQuery(getActivity(), content2);
                    aquery.id(R.id.ivInfoWindowMain)
                            .image(Utility.webSiteAddress + imagePath,
                                    true, true, 0, 0, null,
                                    AQuery.FADE_IN_NETWORK, 1.0f)
                            .visible();

                    Problem problemPass = null;
                    Object[] problemArray = problemSet.toArray();

I also have a custom listview i can show images in custom view using similar code however in map fragment the images aren't shown.

This is the xml file of the marker

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/ivInfoWindowMain"
        android:layout_width="200dip"
        android:layout_height="200dip"
        android:layout_marginRight="5dp"
        android:contentDescription="@string/image"
        android:adjustViewBounds="true" >
    </ImageView>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/txtInfoWindowTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:ellipsize="end"
            android:singleLine="true"
            android:textColor="#ff000000"
            android:textSize="14sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtInfoWindowEventType"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLength="40"
            android:ellipsize="end"
            android:singleLine="true"
            android:textColor="#ff7f7f7f"
            android:textSize="14sp" />
    </LinearLayout>

</LinearLayout>

If you need further information, please let me know. I will update the question immediately. Thanks, in advance.

Barış Akkurt
  • 2,255
  • 3
  • 22
  • 37

1 Answers1

0

I use successfully Google Map Marker and Aquery and first difference is in creating AQuery:

...
AQuery aq = new AQuery(getActivity());
...

and seems that images are used before, I use cache:

...
Bitmap photoMarker = aq.getCachedImage(item.crop);
...
TransactionItem offsetItem = 
                new TransactionItem(item.latitude, item.longitude, photoMarkerSmall, item.id);
mClusterManager.addItem(offsetItem);
...

Try and if not help send if you got any error in LogCat?

ivan.panasiuk
  • 1,239
  • 16
  • 20