デフォルトのマーカーが付いたカスタマイズされたアイテムがたくさんあります。
すべてのマーカーを読み込んだ後、サービスを使用して Drawable 写真を更新しています。新しい写真は 50 X 50 です。
マーカーをタップしてonTapアラートボックスがアクティブになるまで、すべてがうまく機能します。その後、私のマーカーはマーカーの新しい写真の元の(小さい)サイズに戻ります。
これは私のアイテムです:
Bitmap bitmap = ((BitmapDrawable) picture).getBitmap();
picture = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, 50, 50, true));
picture.setBounds(0, 0, 50,50);
marker.getItem(0).setMarker(picture);
mapView.invalidate();
そして、これは私の onTap です:
protected boolean onTap(int index) {
OverlayItem item = mapOverlays.get(index);
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.map_menu);
dialog.setCanceledOnTouchOutside(true);
TextView userName = (TextView)dialog.findViewById(R.id.map_menu_name);
ImageView profilepicture = (ImageView)dialog.findViewById(R.id.map_menu_profile_picture);
if (item.getMarker(0) == null)
profilepicture.setImageDrawable(defaultMarker);
else
profilepicture.setImageDrawable(item.getMarker(0));
userName.setText(item.getTitle());
//dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
dialog.show();
return true;
}
もう1つ、マップの最初の読み込みを使用すると、ダミーマーカーがポイントにあります。マーカーを変更すると、マーカーが少し移動します...理由はわかりません..
編集:以下の回答のおかげで解決策が見つかりました:
私の新しい onTap メソッド:
@Override
protected boolean onTap(int index) {
OverlayItem item = mapOverlays.get(index);
Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.map_menu);
dialog.setCanceledOnTouchOutside(true);
TextView userName = (TextView)dialog.findViewById(R.id.map_menu_name);
ImageView profilePicture = (ImageView)dialog.findViewById(R.id.map_menu_profile_picture);
if (item.getMarker(0) == null)
profilePicture.setImageDrawable(defaultMarker);
else
{
Bitmap bitmap = ((BitmapDrawable) item.getMarker(0)).getBitmap();
Drawable profile = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap, 50, 50, true));
profilePicture.setImageDrawable(profile);
}
userName.setText(item.getTitle());
//dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
dialog.show();
return true;
}