You may need to add a call to 'map.checkResize()'  before you call
'map.setCenter()'

  
http://code.google.com/apis/maps/documentation/reference.html#GMap2.checkResize

In the GWT bindings, this is done so often that there is a convenience
method that combines the two, and checkResize() is called implicitly
whenever the size of the map is changed.  I don't see the map size
being set in your code, but it could be that browser layout is doing
this for you.

On Jan 20, 9:07 am, Marcus <[email protected]> wrote:
> Hey there,
>
> I'm having a problem with my map. In Firefox and Safari, the following
> code creates a map, with the marker centralized on the canvas. In
> Internet Explorer 6 & 7, the marker is placed top-left (at the correct
> position on the map), but not centrally on the canvas. If anyone can
> help, it's driving me mad.
>
> var map = null;
> var geocoder = null;
> var zoom = 13;
> var lat = 51.7826548;
> var lng = -5.1020046;
> var addr = "Broad Haven, Pembrokeshire, United Kingdom";
> var marker = null;
> var center = null;
>
> function map_init()
> {
>   if(GBrowserIsCompatible())
>   {
>     map = new GMap2(document.getElementById("map_canvas"));
>     if(lat == 0 && lng == 0)
>     {
>       geocoder = new GClientGeocoder();
>       geocoder.getLatLng(addr, function(point) { if(point) { center =
> point; continue_init(); } else { zoom = 1; center = new GLatLng(0, 0);
> continue_init(); } } );
>     } else {
>       center = new GLatLng(lat, lng);
>       continue_init();
>     }
>   }
>
> }
>
> function continue_init()
> {
>   map.setCenter(center, zoom);
>   marker = new GMarker(center);
>   map.addOverlay(marker);
>   map.addControl(new GSmallMapControl());
>
> }
>
> So, the marker is correctly placed, and the lat/lng is found
> perfectly. It's just that in Internet Explorer the given lat/lng is
> top-left aligned on the canvas and there is grey space to the right,
> where the map ends. It is as if in IE, the map rectangle is not being
> positioned correctly on the canvas.
>
> Many thanks,
>
> Marcus
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to