My problem is realy simple. After creating a map by using the following code, the center of the map is not well placed.
var myOptions = {
center: new google.maps.LatLng(47.000059, 2.06543),
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scaleControl: false,
streetViewControl: false,
mapTypeControl: false,
};
var activity_map = new google.maps.Map(document.getElementById("activity-map"), myOptions);
This point is the middle of France. My div is a 200x200px block with an hidden overflow and relative position. It’s seems the expected center is placed in the top left and corner of the div. I’ve already tried to change the zoom level, set the center after initialize the map but it didn’t work.
The problem is not in the code you provided. The “top left corner” issue is when the div that contains map doesn’t have a size when the map is initialized. You haven’t provided the HTML/CSS that specifies the size of the map (or that displays it if it is initially hidden).
Another possibility is that you are initializing the map before DOM is completely rendered, you should be initializing it after the DOM ready or body onload event fires.