Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center map on marker click to show whole InfoWindow

Ok, by default on marker click, marker is centred on the map. The problem is, that i have high infoView, inflated from layout, and it show out of map bounds. What can i do, to center pin horizontaly, and position it below map center, to make infoWindow visible.

like image 577
Drake29a Avatar asked Apr 19 '13 10:04

Drake29a


People also ask

How do you change the InfoWindow position on Google Maps?

An InfoWindow can be placed on a map at a particular position or above a marker, depending on what is specified in the options. Unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened. After constructing an InfoWindow, you must call open to display it on the map.

How do I put InfoWindow on marker?

Move an info windowAttach the info window to a new marker using the InfoWindow. open() method. Note: If you call open() without passing a marker, the InfoWindow will use the position specified upon construction through the InfoWindowOptions object literal.

How do I show multiple Infowindows on Google Maps?

Initialize google. maps. InfoWindow() for info windows popup. Loop through the locations (markers) and set the marker position with options (position, map, title, etc.)

How do you call the marker click function from outside the map?

addListener(marker, 'click', (function(marker, i) { return function() { infowindow. setContent(locations[i][0]); infowindow. open(map, marker); } })(marker, i)); iconCounter++; } function AutoCenter() { // Create a new viewpoint bound var bounds = new google. maps.


1 Answers

So I ended up with this solution, it works like a charm. I`m opening infoWindow after animation.

int zoom = (int)map.getCameraPosition().zoom
CameraUpdate cu = CameraUpdateFactory.newLatLngZoom(new 
LatLng(arg0.getPosition().latitude + (double)90/Math.pow(2, zoom), 
arg0.getPosition().longitude), zoom);
map.animateCamera(cu,500,null);
like image 158
Drake29a Avatar answered Nov 20 '22 23:11

Drake29a