Answer the question
In order to leave comments, you need to log in
How to open google map in modal window?
Friends! Can you please explain why the Google map does not work in the modal window?
Rather, it works, and there are no errors, but it is not LOADED until you "kick" it with the cursor.
Why is it so? How to force it to be loaded together with a window?
Here is an example https://codepen.io/Cheizer/pen/jOERLOM
modal window using arctmodal script https://arcticlab.ru/arcticmodal/#examples
Answer the question
In order to leave comments, you need to log in
In general, if you hide a block with a map according to the principle of display none block. It is enough to execute the resize event for the map.
Or push it into a separate function and call it when necessary, or on an on click event
function showMap(){
google.maps.event.trigger(map, 'resize');
}
//или
$('#btn').on('click', function() {
showMap();
google.maps.event.trigger(map, 'resize'); //или сразу
});
$('.get-direction').on('click',function() {
// if map is null (the first time), initiate Google maps;
if (! map) {
initialize();
}
searchAddress( $(this).html() );
showMap();
});
$('.close-map').click(function() {
hideMap();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question