On May 25, 6:56 pm, Stephan Kristyn <[email protected]>
wrote:
> Does anybody know a way to center a map appropiately with the API? It
> does not work with my example:http://www.bamotex.de/neu(click on the
> small ' i ' in the blue box)
>
> function initialize() {
>   if (GBrowserIsCompatible()) {
>         var map = new GMap2(document.getElementById("map_canvas"));
>         map.setCenter(new GLatLng(48.158013,11.45732), 15);
>         map.addOverlay(new GMarker(48.158013,11.45732), 15);
>         map.setUIToDefault();
>   }
>
> }

SetCenter is working perfectly.  It is centering the marker on the
map, but the API thinks the map has zero size (because that is what
the browser reports).

Try searching for "top left".  This is the typical result of a div
that is hidden (has zero size) when the map is created.
2 options to fix it:
1. use the optional "size" parameter in the options field of the GMap2
constructor.
2. call map.checkResize() after the div has been displayed.

  -- Larry

-- 
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