Setting Google Map v3 size on map options

2019-07-31 17:55发布

问题:

I am trying to set up Google map (v3) inside Joomla tabs but there is display problems on map.

If i move away from tab where the map is and change back map canvas is grey and map is displayed only partially on left corner of map canvas.

Image with screen capture:

I get this worked on other site by setting map size on map parameters but there was used Google map version 2 and i could not find correct syntax for setting map size on version 3 map.

Map options are set in global variable.

var mapoptions = {
    zoom: 6,       
    center: new google.maps.LatLng(60, 50),       
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    gridSize: 50,
    size(600, 700, 'px', 'px')
}

What is the correct syntax of map size or is there other solution for this?

I have tested resize function and playing with zoom but those was not helped.

回答1:

I got this solved by adding short delay (100ms) before map initializing function call.

Maybe map canvas did not get fully rendered before google map was accessing it.