3

ここに画像の説明を入力私は Google マップ v2 を使用してアプリを開発しています。アプリには、URL から画像を読み込んでいない (画像ローダーによる読み込み) カスタム情報ウィンドウがあります。詳細については、添付の画像を参照してください。私のコードはここにあります-

public class CustomWindowAdapter implements InfoWindowAdapter {
private Activity objactivity;
private List<GroupDealModle> mapList;

public CustomWindowAdapter(Activity objactivity,
        List<GroupDealModle> mapList) {
    this.objactivity = objactivity;
    this.mapList = mapList;
}

@Override
public View getInfoContents(Marker objmarker) {
    return null;
}

@Override
public View getInfoWindow(Marker objmarker) {
    View objview  = render(objmarker);
    return objview;
}

private View  render(Marker objmarker) {
    ImageLoader objloader = new ImageLoader(objactivity);
    View view = null;
    if (!objmarker.getTitle().equals("")) {
        int pos = Integer.parseInt(objmarker.getTitle());
        Log.e("==check position==", "" + pos);
        if (mapList != null && mapList.size() > pos) {
            String countvalue = mapList.get(pos).getCount();
            Log.e("==check count==", "" + countvalue);
            if (countvalue.equalsIgnoreCase("1")) {
                LayoutInflater inflater = (LayoutInflater) objactivity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.balloon_overlay, null, false);
                TextView objbusname = (TextView) view
                        .findViewById(R.id.balloon_item_title);
                TextView objballoon_item_desc = (TextView) view
                        .findViewById(R.id.balloon_item_desc);
                TextView objtitle = (TextView) view
                        .findViewById(R.id.balloon_item_snippet);
                ImageView objimgview = (ImageView) view
                        .findViewById(R.id.userthumb_inbaloon);
                TextView objtextexpired = (TextView) view
                        .findViewById(R.id.textexpired);

                objbusname.setText(mapList.get(pos).getBussiness_name());
                String expirevalue = mapList.get(pos).getExpire_status();
                if (expirevalue != null && expirevalue.equals("1")) {
                    objtextexpired.setVisibility(View.VISIBLE);
                }
                if (expirevalue != null && expirevalue.equals("0")) {
                    objtextexpired.setVisibility(View.GONE);
                }

                objtitle.setText(mapList.get(pos).getDeal_title());
                objballoon_item_desc.setText(mapList.get(pos)
                        .getDescription());
                String imageurl = mapList.get(pos).getImage();
                objloader.DisplayBanner(AppConstants.BASE_URL + imageurl,
                        objimgview, 65, 65);
            } else {
                LayoutInflater inflater = (LayoutInflater) objactivity
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                view = inflater.inflate(R.layout.transparentview, null, false);
                view.setVisibility(View.GONE);
                String userid = mapList.get(pos).getUser_id();
                LatLng objlatlng = objmarker.getPosition();
                double latitude = objlatlng.latitude;
                double longitude = objlatlng.longitude;
                Bundle objbundle = new Bundle();
                Intent objintent = new Intent(objactivity,
                        com.flashdeal.map.MapGroupData.class);
                objbundle.putString("from", "map");
                objbundle.putString("lat", "" + latitude);
                objbundle.putString("longi", "" + longitude);
                objbundle.putString("userid", "" + userid);
                objintent.putExtras(objbundle);
                objactivity.startActivity(objintent);
            }
        }
    }
    return view;

}

}

サーバーからデータをダウンロードした後のこのアダプター呼び出し-

@Override
    protected void onPostExecute(List<GroupDealModle> result) {
        if (objprogress.isShowing()) {
            objprogress.dismiss();
        }
        if (result != null) {
            mapList = result;
            myMap.setInfoWindowAdapter(new CustomWindowAdapter(MainActivity.this,mapList));

            if (result.size() != 0) {
                if (result != null) {
                    addPins(result);
                }
            } else if (frommovecurrent != null
                    && frommovecurrent.equalsIgnoreCase("yes")) {
                frommovecurrent = "no";
                addSingleMarker();
                addPins(result);

                /*
                 * // objLayout . removeAllViews (); // objLayout .addView(
                 * objviewformap ); objMapViewhelper . clearMap( );
                 * AlertDialog .Builder objbuilder = new AlertDialog
                 * .Builder( MainActivity .this); objbuilder . setMessage (
                 * "No deals found" ); objbuilder . setPositiveButton ("ok",
                 * new DialogInterface . OnClickListener () {
                 * 
                 * @Override public void onClick( DialogInterface arg0, int
                 * arg1) { } }); objbuilder . create(); objbuilder .show();
                 */
            } else if (result.size() == 0) {
                addSingleMarker();
                addPins(result);
            }
        }

    }

私はこのスタックオーバーフローの議論を見ました

Android Google マップ APIv2 InfoWindow とマーカー

しかし、私の問題を解決できません。誰かが私を導いてください。

4

3 に答える 3

1

Google は彼の MAP(Android) を多くの機能で更新し、パフォーマンスを向上させました。GeoPoint を LatLng (場所の緯度のデータ型) に置き換えました。また、MAP v1 と v2 の間の開発者向けの変更

InfoWindow に動的画像を読み込む方法

InfoWindow ビューが作成されると、Google はアクセスしてこのビューを修正または変更できなくなります。しかし、あなたはこれを試すことができます

static HashMap<String,String> loadImagesFlag = new HashMap<String, String>();

*/*create a AsyncTask for load image asynchronously */*

public class FetchImageTask extends AsyncTask<String, Integer, Bitmap> 
{

        @Override
        protected Bitmap doInBackground(String... arg0) {
            Bitmap b = null;
            try {
                Thread.sleep(500);
                b = BitmapFactory.decodeStream((InputStream) new URL(arg0[0]).getContent());
            } catch (MalformedURLException e) {
                //e.printStackTrace();
            } catch (IOException e) {
                //e.printStackTrace();
            }catch (Exception e){
                e.printStackTrace();
            }
            return b;
        }
}

public View getInfoWindow(final Marker marker){

      View view = getLayoutInflater().inflate(R.layout.custome_infowindow, null);
      ImageView driverImage = (ImageView) view.findViewById(R.id.img_driverphoto);
     /* Check this image is already load or not */
     if (DriverImageDTO.isLoadImage(driverName)) {
          /*set Image which is already loaded */
          driverImage.setImageBitmap(DriverImageDTO.DImage);
     }
     else if (!loadImagesFlag.containsKey(driverName)){
        final String vName = driverName;
        /* create HashMap to check status of Image is Load or not */
         loadImagesFlag.put(driverName,"true");
         new com.intelisky.FetchImageTask() {
             protected void onPostExecute(Bitmap result) {
                 if (result != null) {
                    try {
                        if(DriverImageDTO.driverimagelist==null){
                            DriverImageDTO.driverimagelist = new ArrayList<DriverImageDTO>();
                                        }
                            DriverImageDTO.driverimagelist.add(new DriverImageDTO(driverName, result));
                                        marker.setVisible(true);
                                        marker.hideInfoWindow();
                                        getInfoWindow(marker);
                                        marker.showInfoWindow();
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                }
                            }
                        }.execute(imageurl));
                    }

     return view
}
于 2013-12-24T04:40:19.330 に答える