设置ID为谷歌地图API V2标记返回采取相机意向形象 [英] Setting ID to google map API v2 marker to return image taken by camera intent

查看:141
本文介绍了设置ID为谷歌地图API V2标记返回采取相机意向形象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好了,这个问题我已经面临了几天现在似乎无法化解。

Okay, This problem i have been facing for a couple of days now and can't seem to resolve.

这是怎么我的地图作品:

This is how my map works:

  1. 轻按在地图上的任何一点
  2. 在拍照用摄像头意图
  3. 在返回的照片作为标记(缩略图),以窃听说具体点。

(以上所有工作正常)

这就是我坚持:

攻丝上的标记(图像),那么它应该显示较大的标志物的图像作为标记缩略图是相当小的。的问题是,它显示了拍摄的最新图像并没有涉及到该标记的图像。所以我的问题是我怎么可以设置一个标记ID,以便当用户水龙头上标记显示完整的图像。我曾问过这个之前,在这里左右,但不得不改变我的code,这样的图像保存在设备上的文件夹中。也有一个单独的类来创建缩略图。 (不过,我不认为这将使任何区别添加标记ID)

Tapping on the marker (image) it should then display larger image of marker as the marker thumbnail is quite small. The problem is it shows the latest image taken and not the image related to that marker. So my question is how can I set a marker id so that when the users taps on that marker to display the full image. I have asked this before here on SO, but had to change my code so that the images are saved in a folder on the device. Also there is a separate class to create the thumbnail. (however i don't think this would make any difference to adding a marker id)

这是在code的作品,直到在正确显示为标记图像。 (这只是显示了最新的图像拍摄):

This is the code that works up until the correct image is displayed for the marker. (this just displays the latest image taken):

相机意图

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

if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK) {

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

              MarkerOptions markerOptions = new MarkerOptions()
             .draggable(true)
             .snippet("Tap here to remove marker")
             .title("My Marker")
             .position(pointtap)
             .icon(BitmapDescriptorFactory
             .fromBitmap(bitmap));
             googleMap.addMarker(markerOptions);
            }
        }
 }

onMarkerClick

@Override
        public boolean onMarkerClick(Marker marker) {
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                    context);

                // set title
                alertDialogBuilder.setTitle("My Marker");

                // set dialog message
                alertDialogBuilder
                    .setMessage("Select Option")
                    .setCancelable(false)
                    .setPositiveButton("Display full Image",new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface arg0, int arg1) {
                              Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            Uri imgUri = Uri.parse("file://" + fileUri);
            intent.setDataAndType(imgUri, "image/*");
            startActivity(intent);
                        }
                      })

                    .setNegativeButton("Delete Marker",new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {
                            // if this button is clicked, just close
                            marker.remove();
                        }
                    });

                    // create alert dialog
                    AlertDialog alertDialog = alertDialogBuilder.create();

                    // show it
                    alertDialog.show();
                    return false;

我希望有人会这么好心给我看我怎么能实现一个标记ID,以便采取该标记的图像显示,当用户点击该标记全屏。

I am hoping someone would be so kind to show me how i can implement a marker id so that the image taken for that marker is displayed full screen when the user taps the marker.

感谢大家!

更新 不得不实施AlertDialog显示两个选择,一个删除标记,一个显示完整的图像,显​​示完整的图像是我挣扎与显示图像摄于地图上这一点。

UPDATE Had to implement AlertDialog to display two options, one to delete marker and one to display full image, the display full image is the one i am struggling with to display the image taken at that point on the map.

推荐答案

试试这个..

REF。 <一个href="http://stackoverflow.com/questions/27457828/how-to-remove-marker-from-google-map-v2?answertab=oldest#tab-top">How从谷歌地图V2删除标记?)

previously我没告诉you..Just保存标记,以自己的变量.. 并有对每一个marker..Hence索引号的索引号由你提供 和谷歌标志物有自身的ID ......谷歌标志物返回ID与M1,M2或M3 ........所以 只需更换得到marker.getId和替换'M'。现在你可以标记该ID不配合你的索引号。

Previously I did told you..Just save marker to your own variables.. and there are a Index number for each and every marker..Hence Index number is provided by you and Google-Marker have itself ID... Google-Marker return ID with 'm1, m2 or m3...'.. so just replace get marker.getId and replace 'm'.. Now you can get marker this Id do match with your Index number.

//样品code得到标记ID

    String mId = marker.getId();
    mId = mId.replace("m","");
    String clickMarker =  Integer.valueOf(mId);

//因此,i是谷歌,标记编号...你与它有你的标志物指标值..匹配。 //样品code获得点击标记编号

// hence 'i' is Google-Marker Id... and You have your marker Index value.. match with it. // sample code to get Click marker Id

           for(int k = 0; k<myMarkersHash.size(); k++)
            {
                if(clickMarker == myMarkersHash.get(k))
                {
                    // now got k is marker value
                    break;
                }
            }

// myMarkersHash也被定义为参考。链接

这篇关于设置ID为谷歌地图API V2标记返回采取相机意向形象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆