如何在地图活动中声明LatLng点,以便当用户点击地图上的特定点以放置标记时。现在我所做的就是创建一个地图,这样你就可以从地图上的相机意图添加自定义标记。问题不在于它的工作原理,但事实上我必须在地图上的坐标上声明一个“点”,然后在拍摄图像时,它会将该图像的缩略图放在那个位置。
示例:static final LatLng point = new LatLng(xx.xxxx, xx.xxxx);
然后在我的onActivityResult中从相机意图:
MarkerOptions markerOptions = new MarkerOptions()
.position(point)
.icon(BitmapDescriptorFactory
.fromBitmap(bitmap));
googleMap.addMarker(markerOptions);
所以我想要做的就是倾听用户点击的位置并将该图像返回到点击的位置。
有人可以帮忙吗?如果您需要更多信息,请告诉我并更新我的问题。
由于
更新代码
@Override
public void onMapClick(LatLng point) {
root = Environment.getExternalStorageDirectory().toString()
+ "/Your_Folder";
imageFolderPath = root + "/saved_images";
File imagesFolder = new File(imageFolderPath);
imagesFolder.mkdirs();
imageName = "test.png";
File image = new File(imageFolderPath, imageName);
fileUri = Uri.fromFile(image);
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(takePictureIntent,
CAMERA_IMAGE_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data, LatLng point) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case CAMERA_IMAGE_REQUEST:
Bitmap bitmap = null;
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(point)
.icon(BitmapDescriptorFactory
.fromBitmap(bitmap));
googleMap.addMarker(markerOptions);
break;
default:
Toast.makeText(this, "Something went wrong...",
Toast.LENGTH_SHORT).show();
break;
}
}
}
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);
}