Google Maps - Infobox API - scroll pane vs change position - google-maps

Using Google Maps InfoBox -
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/reference.html
Currently the map will scroll - pan control - when your infobox is outside of the bounds of the map.
I'm looking for a way to detect if the infobox will be outside of the bounds of the map, and if so the position is switched (currently I have the infoBoxAnchor set at 9,2) - so set the infoboxanchor in the opposite x direction.
Anyone done anything like this?
Thanks.

Could be tricky - infowindows are dynamically sized based on the content in them. What you could do, is in the InfoWindowOptions, set disableAutoPan=true. This will prevent the map panning to display the infowindow. Then I'm guessing you could use jQuery (or any other JS you like) to figure out:
the size of the infowindow based on the position where it's anchored to on the map,
is the entire infowindow visible
if not, move the infowindow's position

Related:
Auto adjustment of InfoWindow position on Google Maps
Google Maps Mashup with Intelligently positioning InfoBox
Google Maps: How to prevent InfoWindow from shifting the map
And a possible solution (thanks to above links) at http://gmaps-samples-v3.googlecode.com/svn/trunk/smartinfowindow/smartinfowindow.html

Related

Google maps infowindow autopan: is it possible to customize the distance to the map's top?

I have a map with a semi-transparent search bar on top of it. I have also got a bunch of markers with infowindow attached to them.
The problem is that google maps autopan feature obviously doesn't take my search bar into account, therefore if my marker is too close to the top, a part of the infowindow gets covered by the bar.
Is it possible to somehow specify the minimum distance the infowindow needs to be from the map's top?
I was also thinking of limiting the bounds of the map using markers' positions but in my case the markers can also end up under the search bar, so it is not an option.
Any ideas? Thank you for your time!
There exists a library called Snazzy Info Window that can be used instead of the usual InfoWindow. Then you can pass an option edgeOffset in pixels to this object and voila, problem solved. Hope this helps someone in the future!

How can I display an InfoWindow beyond the edge of a Google Map and not pan the map?

I'm using google maps api v3.
I'm displaying InfoWindow,and we know that unless auto-pan is disabled, an InfoWindow will pan the map to make itself visible when it is opened.
But i want to make the infowindow is fully visible when it opens with out pan the map,like intelligently switch the position and dimensions of the InfoWindow depending on where the edge is.
Maybe some would suggest smartinfowindow, but there is some problems with smartinfowindow,you can test it.
Is there any other way?
Thank you very much!

How to check if the markers in a google map are not behind any custom controls in the Map

I'm using Google maps V3 API . I've added a custom control on the Map. Its having a width of 350px and height 300px.
Is there any way which i can figure out any of the marker is positioned behind the custom control on the Google maps.
Also i need to find out if i could able to find any marker is behind the custom control , i want it to change the position of the marker out of the custom control.

Google Maps API: setCenter from markers possible?

I have set of markers on Google map.
Is it possible to center the map in the way that all markers will be visible, and zoom level will also be auto adjusted?
Exactly the same way how Goolge Static Maps API does when you specify markers and do not specify center/zoom parameters (Implicit Positioning of the Map).
You can use var myBounds = google.maps.LatLngBounds() and basically extend all the points you have. Once you have all the points in the LatLngBounds() you can use your map.fitBounds(myBounds); and all marker should be visible and centered.
do you wish me to prototype a jsfiddle?

How can I have a smooth animated move between 2 Google Maps locations?

When clicking from one marker to another in Google Maps, the map screen animates the move smoothly if both markers are within them initial map view but jumps if one of the markers is off screen.
I'm trying to set up a map which has several locations within the main map area but has one which is 'off screen'. I have a signpost icon to the more distant location within the initial map area which I want to smoothly scroll to the off screen location when clicked (so as to give a better sense of it's relative location). I can't find anything in the Maps API which would let me do this however.
I could zoom out, move and then zoom in again but this looks a bit jarring. Am I missing something in the API, or does anyone have any suggestions?
Unfortunately, I don't think this is possible (without a change from Google). From the v3 API reference for panTo:
Changes the center of the map to the given LatLng. If the change is less than both the width and height of the map, the transition will be smoothly animated.
which implies that if that change is not less than the dimensions of the map, the transition won't be smoothly animated. The other pan methods are similar.
You could try moving in multiple steps but that's a bit of a hack and I suspect the result will be poor.
Sorry that's not very helpful (I have the same problem).
For me this method works, but i'm using Google Maps API v2.
LatLng latLng = new LatLng(lat,lng);
map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, ZOOM_FACTOR));
This animates the camera from current position to the new one.
If you are using Gmaps API V2, then you can implement smooth animated move very easily by using panBy() method. You have to use fromLatLngToContainerPixel() method to find the amount of pixels to pan by.
Here is the bit of code:
var newLoc = map.fromLatLngToContainerPixel(new GLatLng(lat, lng));
map.panBy(new GSize( newLoc.x, newLoc.y ));
However, what I am trying to do is to achieve the same thing in maps API V3, but sadly fromLatLngToContainerPixel() method does not work anymore the way it did :(