Answer the question
In order to leave comments, you need to log in
Does Google Map have a ready event?
Hello!
Maybe there is a google map loading end event?
And then I have a block that should be hidden (display: none)
But if it is initially hidden, then the maps are initialized incorrectly (that is, their size is zero)
That's why when loading the page I want to make the block appear before the google map is loaded
Answer the question
In order to leave comments, you need to log in
Why "before"?
Pull at the right time google.maps.event.trigger(MapInstance,'resize')
, the cards will be recalculated.
function initialize() {
var mapOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&sensor=TRUE_OR_FALSE&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question