0

I'm displaying a GoogleMap v2 with plenty of Marker's with their own customized .snippet() layout.

When clicking on a Marker, the map will move itself so the Marker is centered. The snippet will pop up and show itself above the Marker. Now my problem is that the snippet is bigger (higher) than there is space above the Marker!

How can I make the snippet beeing viewed in full size? I want everything of the snippet to be shown, so I don't have to scroll up to read the upper part of the content!

Thanks

Steve Benett
  • 12,843
  • 7
  • 59
  • 79
Sebastian
  • 1,593
  • 4
  • 26
  • 41

1 Answers1

1

You can use the GoogleMap.InfoWindowAdapter to replace the native layout with a custom one.

You would have something like this:

 private GoogleMap mMap;
 mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

        @Override
        public View getInfoWindow(Marker arg0) {
             
             View v = getLayoutInflater().inflate(R.layout.your_custom_layout, null);
             return v;

        }

        @Override
        public View getInfoContents(Marker arg0) {

             return null;    
        }
    });

Now you can alter the size / look of the info window through your own layout.

  • The getInfoWindow() will replace the info window frame.
  • The getInfoContents() will replace the content of the info window by using the standard frame. It will fire only if getInfoWindow() returns null.

But AFAIK this is limited. You can't add Views, which response to click listeners f.e.

Community
  • 1
  • 1
Steve Benett
  • 12,843
  • 7
  • 59
  • 79
  • Thanks for the help, but I am using this method already to display my custom content. Those the content is bigger than 50% of the screen, making the upper remaining place invisible (out of the screen) – Sebastian Oct 19 '13 at 12:39
  • 50% of the screen is no trouble.. Just place the map with the marker on bottom of the screen, when the user clicks on it. – Steve Benett Oct 19 '13 at 12:44
  • Sounds reasonable. How do I move the camera to some specific LatLng respecting the marker shoud be on the bottom of the screen, as described in your comment? – Sebastian Oct 19 '13 at 12:56
  • Have a look at the edit of this [question](http://stackoverflow.com/questions/16764002/how-to-center-the-camera-so-that-marker-is-at-the-bottom-of-screen-google-map). – Steve Benett Oct 19 '13 at 13:19
  • Thanks solved the problem already by myself. Am about to post it here – Sebastian Oct 19 '13 at 14:47