2

I have a screen with google map, on top of screen there is one AutotextView for search place, and make a custom info window to show more details, problem is when user click on any mark custom window popup as their default behaviour (center on screen), so it mixed up autotextview, Can I change info-window position on screen, i.e bottom or anything like that.

Hitesh Dhamshaniya
  • 2,886
  • 3
  • 24
  • 31

3 Answers3

5

If you want to adjust Marker location perfect center on google map screen with popup then please use below code in that i have get popup height and based on that update y axis.i hope it will help you.

public boolean onMarkerClick(Marker marker) {

        //Please use fix height popup
        float container_height = getResources().getDimension(R.dimen.DIP_300);

        Projection projection = mGoogleMap.getProjection();

        Point markerScreenPosition = projection.toScreenLocation(marker.getPosition());
        Point pointHalfScreenAbove = new Point(markerScreenPosition.x,(int) (markerScreenPosition.y - (container_height / 2)));

        LatLng aboveMarkerLatLng = projection.fromScreenLocation(pointHalfScreenAbove);

        marker.showInfoWindow();
        CameraUpdate center = CameraUpdateFactory.newLatLng(aboveMarkerLatLng);
        mGoogleMap.moveCamera(center);
        mGoogleMap.animateCamera(center);
        marker.showInfoWindow();

        return true;


}
Piyush
  • 5,607
  • 4
  • 27
  • 27
0

Currently you cannot change the info window to be below marker. This is already requested and discussed on gmaps-api-issues.

I can only suggest you to animate marker after being clicked to a different position. Add OnMarkerClickListener and return true (handled) there. After that you can call:

marker.showInfoWindow();
map.animateCamera(...);

to create an effect similar to default but with a different position.

MaciejGórski
  • 22,187
  • 7
  • 70
  • 94
0

Google Map Info Window Position always on top middle of marker now. If marker is rotated.

double angle = MARKER_ROTATION_ANGLE;
double x = Math.sin(-angle * Math.PI / 180) * 0.5 + 0.5;
double y = -(Math.cos(-angle * Math.PI / 180) * 0.5 - 0.5);
marker.setInfoWindowAnchor((float)x, (float)y);

Explanation: instead of MARKER_ROTATION_ANGLE you have to give the exact rotation of your marker. Then it will be work fine. :)

Nihas Nizar
  • 619
  • 8
  • 15