是否可以点击谷歌地图api v2中的标记(缩略图)并放大“放大”

时间:2014-12-16 08:29:00

标签: android android-image android-maps-v2

我有一个基本上是缩略图的标记。所以我想知道的是,是否可以点击缩略图并显示更大的缩略图,有点像炸毁或放大缩略图?抱歉这个简短的问题。我目前没有任何代码,但如果有人可以提供帮助,我会随时发布代码。

相机意图:

Intent getCameraImage = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
         getApplicationContext().getDir(
                 getResources().getString(R.string.app_name), MODE_PRIVATE);

         fileUri = Uri.fromFile(new File((Environment.getExternalStorageDirectory() +
                 "/" +getResources().getString(R.string.app_name)),new Date().getTime() + ".jpg"));

            getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

         startActivityForResult(getCameraImage, TAKE_PICTURE);

        }    

onActivityResult

try {
                  GetImageThumbnail getImageThumbnail = new GetImageThumbnail();
                  bitmap = getImageThumbnail.getThumbnail(fileUri, this);
              } catch (FileNotFoundException e1) {
                  e1.printStackTrace();
              } catch (IOException e1) {
                  e1.printStackTrace();
              }
              {


              MarkerOptions markerOptions = new MarkerOptions()
             .position(theLastPlaceThatTheUserLongClicked)
             .icon(BitmapDescriptorFactory
             .fromBitmap(bitmap));
             googleMap.addMarker(markerOptions);
            }
        }
 }

showFullImage

public void showFullImage(View view) {
String path = (String) view.getTag();

if (path != null) {

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri imgUri = Uri.parse("file://" + path);
    intent.setDataAndType(imgUri, "image/*");
    startActivity(intent);
   }
 }
}

那么如何将showFullImage实现到onMarkerClick

onMarkerClick

 @Override
        public boolean onMarkerClick(final Marker marker) {
     return false;
 }

2 个答案:

答案 0 :(得分:0)

你能做的是

myMarker= map
            .addMarker(new MarkerOptions()
                    .position(pos)
                    .title(getResources().getString(R.string.reachUs))
                    .snippet("We are here")
                    .icon(BitmapDescriptorFactory
                            .fromResource(R.drawable.logo_small)));

在谷歌地图对象上调用setInfoWindowAdapter()方法,并通过先删除它来为smae marker设置一个更大的图像

map.setInfoWindowAdapter(new InfoWindowAdapter() {

        // Use default InfoWindow frame
        @Override
        public View getInfoWindow(Marker arg0) {
            return null;
        }

        // Defines the contents of the InfoWindow
        @Override
        public View getInfoContents(Marker arg0) {

        myMarker.remove();
        myMarker= map
            .addMarker(new MarkerOptions()
                    .position(pos)
                    .title(getResources().getString(R.string.reachUs))
                    .snippet("We are here")
                    .icon(BitmapDescriptorFactory
                            .fromResource(R.drawable.logo_large)));

            return v;

        }
    });

如果您想再次缩小,请使用切换或标记再次设置小图像。

只需在标记上使用remove()就可以了

答案 1 :(得分:0)

您应该处理标记点击事件并获取图像

 myMap.setOnMarkerClickListener(MarkerClickListener);

然后你必须从标记中获取图像并在单独的图像视图中显示。 要缩放或吹动图像,您可以使用任何缩放API来显示图像 Like Here

相关问题