I am trying to display google map into the Twitter bootstrap modal.
When user first click on the button Show map
then he is able to see the map successfuly as i
I will use uiGmapIsReady wait the dom ready then force the map resize:
uiGmapIsReady.promise().then(function () {
var map = $scope.map.control.getGMap();
google.maps.event.trigger(map, 'resize');
});
The visibility:hidden
and visibility:visible
could be used instead of display:none
and display:block
. This worked for me. You can even edit the CSS of the modal for this.
well this is how the answers above helped but I had to call the main function using onclick
.
<span data-target="#enlargeModal"data-toggle="modal" onclick="newMap()" class="fa fa-expand r"></span>
function newMap()
{
function showMap() {
//your map function
}
$('#enlargeModal').on('shown.bs.modal', function () {
var center = fullmap.getCenter();
google.maps.event.trigger(fullmap, 'resize');
fullmap.setCenter(center);
});
showMap(); }
I had the same issue. but I found an issue with modal shown event. as its not working with some version of issue so I just follow the bootstrap modal documentation to achieve it.
Bootstrap Modal Map Issue Solution :
$(document).ready(function(){
$('#locationMap').on('shown.bs.modal', function(){
google.maps.event.trigger(map, 'resize');
map.setCenter(new google.maps.LatLng(-33.8688, 151.2195));
});
});
Finally This works for me, It could help to someone.