Alfred Neuman
Alfred Neuman

Reputation: 11

Re-set the scroll bar for a Google Maps infowindow that's in a sidebar

I'm a bit new to this, but I've got a Google Map based on a Fusion Tables document. I've suppressed the default infowindow, so all the infowindow content now appears in a sidebar at the left of the map.

When you click on a location that has a lot of information, a scroll bar appears in the sidebar. But if you scroll to the bottom, then click on another marker that contains a lot of information, the sidebar stays 'scrolled' at roughly the bottom of the window. Ideally, I'd like the sidebar window to be scrolled to the top every time a location marker is click. Any suggestions would be greatly appreciated.

Here's the code that is running the map:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  function initialize() {
    google.maps.visualRefresh = true;
    var map = new google.maps.Map(document.getElementById('googft-mapCanvas'), {
      center: new google.maps.LatLng(22.538753, 18.037109),
      zoom: 2,
      panControl: false,
      zoomControl: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP,

    });

    layer = new google.maps.FusionTablesLayer({
      map: map,
      suppressInfoWindows: true,
      heatmap: { enabled: false },
      query: {
        select: "col0",
        from: "1p1iLd40kwI3p-krwucgAxxZvhknmiFuZgHk0Q_g",
        where: ""
      },
    options: {
    styleId: 2,
    templateId: 2
      }
    });

    google.maps.event.addListener(layer, 'click', function(e) {
        document.getElementById("sidebar").innerHTML = e.infoWindowHtml;

}); 

  }

  google.maps.event.addDomListener(window, 'load', initialize);

</script>

Upvotes: 0

Views: 258

Answers (2)

Alkis Kalogeris
Alkis Kalogeris

Reputation: 17745

I believe this is sufficient

google.maps.event.addListener(layer, 'click', function(e) {
        var sidebar = document.getElementById("sidebar");

         sidebar.innerHTML = e.infoWindowHtml;
         sidebar.scrollTo(0, 0);
}); 

Upvotes: 0

Alfred Neuman
Alfred Neuman

Reputation: 11

I'm afraid that didn't work but I did find a solution:

google.maps.event.addListener(layer, 'click', function(e) {
        var sidebar = document.getElementById("sidebar");

        sidebar.inner HTML = e.infoWindowHtml;
        sidebar.scrollTop = 0;

I don't know why the other solution didn't work.

Upvotes: 1

Related Questions