views:

64

answers:

0

hi,

I'm having a particular fight with Google Maps v2 on Chrome. The map is shown well on all browsers except Chrome, that without any particular reason, it does any of these things as you can see on the image:

  • Moving the center to the south
  • Showing the markers to the right, but if i move the map, they moved too to the next section of the map.
  • Perfect

google maps and chrome

I have the following javascript:

if (GBrowserIsCompatible()) {
  var map = new GMap2(document.getElementById("map"));
  var bounds = new GLatLngBounds();
  map.enableScrollWheelZoom();
  map.addControl(new GSmallMapControl());
  map.addControl(new GMapTypeControl());
  map.removeMapType(G_HYBRID_MAP);
  var zoomout = 1;

  var pcenter_0 = new GLatLng(40.420300, -3.705770);
  var marker_0 = new GMarker(pcenter_0, {draggable: false});
  map.addOverlay(marker_0);
  marker_0.bindInfoWindowHtml('info', {pixelOffset:new GSize(32,5), maxWidth:200} );
  bounds.extend(marker_0.getPoint());

  var pcenter_1 = new GLatLng(41.385719, 2.170050);
  var marker_1 = new GMarker(pcenter_1, {draggable: false});
  map.addOverlay(marker_1);
  marker_1.bindInfoWindowHtml('', {pixelOffset:new GSize(32,5), maxWidth:200} );
  bounds.extend(marker_1.getPoint());

  var pcenter_2 = new GLatLng(48.856918, 2.341210);
  var marker_2 = new GMarker(pcenter_2, {draggable: false});
  map.addOverlay(marker_2);
  marker_2.bindInfoWindowHtml('info', {pixelOffset:new GSize(32,5), maxWidth:200} );
  bounds.extend(marker_2.getPoint());

  var pcenter_3 = new GLatLng(37.779160, -122.420052);
  var marker_3 = new GMarker(pcenter_3, {draggable: false});
  map.addOverlay(marker_3);
  marker_3.bindInfoWindowHtml('', {pixelOffset:new GSize(32,5), maxWidth:200} );
  bounds.extend(marker_3.getPoint());

  var pcenter_4 = new GLatLng(48.202541, 16.368799);
  var marker_4 = new GMarker(pcenter_4, {draggable: false});
  map.addOverlay(marker_4);
  marker_4.bindInfoWindowHtml('', {pixelOffset:new GSize(32,5), maxWidth:200} );
  bounds.extend(marker_4.getPoint());

  zoomToBounds(zoomout);
}

function zoomToBounds(zoomout) {
map.setCenter(bounds.getCenter());
var zoom = map.getBoundsZoomLevel(bounds)-zoomout;
if(zoom < 1) zoom = 1;
map.setZoom(zoom);
map.checkResizeAndCenter();
}

Do you have any idea or clue of what can be happening? It's very annoying to have this random javascript errors.. If you need more info, please ask!

thanks!

Update to add html code (before javascript)

<div id="index_map"> 
  <div id="map"></div> 
</div> 

I've aldo updated the markers code