L
L
lightalex2015-02-11 17:13:23
JavaScript
lightalex, 2015-02-11 17:13:23

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

2 answer(s)
L
Leonid Sysoletin, 2015-02-11
@lightalex

Why "before"?
Pull at the right time google.maps.event.trigger(MapInstance,'resize'), the cards will be recalculated.

H
holfza, 2015-02-11
@holfza

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;

https://developers.google.com/maps/documentation/j...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question