It works but.... now there is another problem. It seems to glitch and pan the map in the wrong direction if you have zoomed to a town level, and then click a sidebar link.
You can have a look at the functionality and see what I mean on this temporary link: http://illustriousworks.ie/index.php/travelpoint/tp_ie_testing_fixed/ The code is very messy so advanced apologies! On Jul 13, 12:07 pm, Andrew Leach <[email protected]> wrote: > On Jul 13, 11:41 am, ShaneMcC <[email protected]> wrote: > > > > > Is there anyway to center the infowindow when a sidebar entry is > > clicked? > > Yes, but not in your code snippet. > > You need to change what happens when the marker is clicked (which is > what the sidebar link does: it "clicks" the marker automatically), so > the bit you need to change is that listener: > > GEvent.addListener(marker, "click", function() { > marker.openInfoWindowHtml(html); > }); > > Set the map centre before opening the infoWindow, in order that the > marker is in view but the infoWindow will scroll the map so it all > fits: > > GEvent.addListener(marker, "click", function() { > map.setCenter(marker.getLatLng()); > marker.openInfoWindowHtml(html); > }); > > If you can't get that to work, post a link to *your* map, not to one > which works. -- You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
