javascript - How to use map.getCenter() and google.maps.event.trigger() -


i'm using gmap module. if try initialise map on hidden div, fail display.

we can use google.maps.event.trigger(map, 'resize'); in script, because got map on top left corner.

i found solution map.getcenter(); map.setcenter(); when use in js file inside tabs custom code, doesn't work, because "map" not defined.

is there solution this?

here's code:

$(document).ready(function(){          $('.spoiler-body1').hide();          $('.spoiler-head').click(function(){              var mapobj = window[$('.bx-google-map').attr('id')];             var center = mapobj.getcenter();              $(this).toggleclass("folded1").toggleclass("unfolded").next().slidetoggle();              google.maps.event.trigger(mapobj, 'resize');              mapobj.setcenter(center);         });     }); 

i presume have map initialize on separate window.onload (or equivalent). script needs run after map initialization. happening this window.onload runs before other 1 initialization script, though technically fire @ same time.

this can fixed appending script map initialization directly. guarantee timing lines up.


Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -