如何放置在地图相机意图和地点拍摄的照片,用户已经聘请(在地图上点)在地、意图、图上、地点

2023-09-07 01:02:42 作者:冷劍℡

我曾问一个关于拍摄照片并返回一个形象的地步,用户已经选定在地图上的问题。 previously相机意图将崩溃了它现在没有崩溃的应用程序工作,但现在有把图像回地图的问题。这是我更新code:

I have asked a question about taking a photo and returning that image to the point on the map where the users has tapped. Previously the camera intent would crash got it now to work without crashing the app but have the problem now of placing the image back into the map. Here is my updated code:

  @Override
  public void onMapLongClick(LatLng point) {
  Intent getCameraImage = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File cameraFolder;
    if  (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
        cameraFolder = new File(android.os.Environment.getExternalStorageDirectory(),"myfolder/");
    else
        cameraFolder= context.getCacheDir();
    if(!cameraFolder.exists())
        cameraFolder.mkdirs();
    String imageFileName = imagename;
    photo = new File(cameraFolder, "myfolder/" + imageFileName);
    getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
    Uri.fromFile(photo);
    startActivityForResult(getCameraImage, TAKE_PICTURE);

}    

protected void onActivityResult(int requestCode, int resultCode, LatLng point) { 
    if(resultCode == RESULT_OK) {
        // This code here i think is wrong? 
        googleMap.addMarker(new MarkerOptions().position(point)
                .icon(BitmapDescriptorFactory.fromFile("photo")));
    }
}

当我拍摄照片并返回到地图,那么这就是我从日志中获得:

when i take the photo and return to maps, then this is what i get from the log:

11-23 09:32:31.837: D/skia(12895): GFXPNG PNG bitmap created width:256 height:256 bitmap id is 486 

所以,在我的脑海它似乎是工作,但不能将图像中的地图。谁能请帮助?

So in my mind it seems to be working, but not placing the image in the maps. Could anyone please help?

推荐答案

我不认为你在日志中看到的消息与照片图像 - 尺寸256×256像素的是摄像头太小,除非你指定它在某种程度上当拍照。这是不可能的。

I do not think that the message you see in the log relates to the photo image - size 256x256 px is too small for camera, unless you specified it somehow when taking picture. It is unlikely.

在code中的问题是与 BitmapDesc​​riptorFactory.fromFile(照片),你应该使用类似 BitmapDesc​​riptorFactory.fromPath( photo.getAbsolutePath())

The problem in your code is with BitmapDescriptorFactory.fromFile("photo"), you should use something like BitmapDescriptorFactory.fromPath(photo.getAbsolutePath()).