Google Maps - InfoWindow Position Problem

Discussion in 'JavaScript' started by Jawn, Jan 26, 2010.

  1. #1
    Hello guys

    Im trying to create a map with a few markers and each marker has a Infowindow. Problem is that the InfoWindows doesnt open above the marker but opens at one specific place whenever you click a marker.

    Searched the internet for awhile now and couldnt find how to position the InfoWindow.

    Here's the code

    
    // Display the map, with some controls and set the initial location 
    var map = new GMap2(document.getElementById('map'));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());		      
    map.setCenter(new GLatLng(48.86335963646481, 2.35107421875), 11);
    
    // Marker 1
    var icon = new GIcon();
    icon.image = "/i/hotel-pointer-cheap.png";
    icon.shadow = "/i/hotel-pointer-shadow.png";
    icon.iconSize = new GSize(32, 32);
    icon.shadowSize = new GSize(59, 32);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(48.87146,2.34304);
    var marker = new GMarker(point,icon);
    
    GEvent.addListener(marker, 'click', function() { 
    	marker.openInfoWindowHtml('Some text'); 
    });
    map.addOverlay(marker);
    
    
    // Marker 2	
    var icon = new GIcon();
    icon.image = "/i/hotel-pointer-cheap.png";
    icon.shadow = "/i/hotel-pointer-shadow.png";
    icon.iconSize = new GSize(32, 32);
    icon.shadowSize = new GSize(59, 32);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(48.87198,2.34349);
    var marker = new GMarker(point,icon);
    						
    GEvent.addListener(marker, 'click', function() { 
    	marker.openInfoWindowHtml('Some text'); 
    });
    map.addOverlay(marker);
    			
    						
    // Marker 3				
    var icon = new GIcon();
    icon.image = "/i/hotel-pointer-cheap.png";
    icon.shadow = "/i/hotel-pointer-shadow.png";
    icon.iconSize = new GSize(32, 32);
    icon.shadowSize = new GSize(59, 32);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);
    var point = new GLatLng(48.87062,2.35164);
    var marker = new GMarker(point,icon);
    						
    GEvent.addListener(marker, 'click', function() { 
    	marker.openInfoWindowHtml('Some text'); 
    });
    map.addOverlay(marker);
    
    PHP:

    Works fine with one marker but with several it gets messed up?

    Best Regards
    Jawn
     
    Jawn, Jan 26, 2010 IP
  2. Jawn

    Jawn Peon

    Messages:
    200
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nm got it sorted out after a few hours :p
     
    Jawn, Jan 27, 2010 IP