I have issue same as Issue 1448: Bug: API v3 needs a checkResize() function (or equivalent) where my map not fully loaded and not center.
I have marker but after resize it moved to top left (hidden). Just move a little bit and u can see it.:mad:
I think the problem is getting the google map object - I don’t think you can retrieve it just from the DOM element. The code that controls the map, /mod/Gmap_Geo/js/map.min.js, is there a website/docs for it?
Thanks for sending me the info. I think I’ve got a solution for you.
In the map.js file, change this line:
var map = new Map(address, desctot, title, markerico, spanId);
to
window.map = new Map(address, desctot, title, markerico, spanId);
and then change your html file to link to map.js instead of map.min.js. If this solution works for you, you can always re-minify the code using a service like http://jscompress.com/.
Also, you need to modify the JS in your page:
// The tab 'shown' event seems to cause less flicker for me
$('a[href="#tab2"]').on('shown', function (e) {
initialise();
});
function initialise() {
var myMap = document.getElementById('map-myid1');
google.maps.event.trigger(myMap, 'resize');
map.map.setCenter(map.marker.getPosition()); // Add this line to recentre the map
};
Note: I’ve only tested this on Chrome so far, but it works for me.