Setting ID to google map API v2 marker to return image taken by camera intent

后端 未结 2 845
灰色年华
灰色年华 2021-01-15 23:54

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. Tap on any point on map
2条回答
  •  情书的邮戳
    2021-01-16 00:43

    If you are not using the markers InfoWindow you could set the InfoWindows title or snippet to your id and then retrieve it. I do this with

    myMap.addMarker(new MarkerOptions()
        .title(myTitle)
        .snippet(mySnippet)
        .position(myPosition));
    

    Then to retrieve the id just use:

    myMarker.getTitle()
    

    or

    myMarker.getSnippet()
    

    Here is the example to use the snippet as a tag for the marker:

    public class CustomInfoWindow implements InfoWindowAdapter {
    
        @Override
        public View getInfoContents(Marker marker) {
            View v = LayoutInflater.from(AppCtxProv.getContext()).inflate(R.layout.custom_info_window, null);
            TextView title = (TextView) v.findViewById(R.id.title);
            title.setText(marker.getTitle());
            return v;
        }
    
        @Override
        public View getInfoWindow(Marker marker) {
            return null;
        }
    
    }
    

    Then for the custom layout I used this simple code:

    
    
    
            
    
    
    

    The AppCtxProv is an Activity class I created that just returns the context:

    public class AppCtxProv extends Application {
    
        @Override
        public void onCreate() {
            super.onCreate();
        }
    
        public static Context getContext() {
            return getApplicationContext();
        }
    
    }
    

    And in the manifest just give the

    android:name="your.package.AppCtxProv"
    

    attribute to the Application tag

提交回复
热议问题