Greetings,

A well documented issue with google maps is that they render incorrectly in modals, which is an increasingly common way of presenting maps to website visitors. This fantastic module should include some built in support for maps displayed in modals like Bootstrap modal or other popular modals.

This issue occurs with any modals (basically all of them!) that originally have a ‘display: none’ css property defined. When the div with the map loads/renders, the property value changes to block (‘display: block’).

The solution is to re-size the map when the modal loads since it now has a new new width and height. So if we can integrate something like google.maps.event.trigger(map, 'resize'); into the google map js so that module users can easily call the event from their theme js like so, that would be great.

$('#mymodal').on('shown', function () {
google.maps.event.trigger(map, 'resize');
});

Any thoughts on this, Rob? Cheers, Kevin

Comments

RdeBoer’s picture

Great idea Kevin,

I'll think about this one. In the mean time if you have a patch handy, that would be great.

Also for all you Google map lovers... in the IPGV&M Views UI, when you select the format, just try for once "Map (IPGV&M via Leaflet API)" (requires the http://drupal.org/project/leaflet module), rather than "Map (IPGV&M via Google API)".
This will still display your favorite Google Map (provided you have enabled http://drupal.org/project/leaflet_more_maps also), but see how that same map suddenly doesn't have all those CSS issues anymore. And look at all the options you get thrown in for free by making the switch.
If you don't like it, you can alway switch that radio button back to what you had before!

Example: http://regionbound.com/coffee-prices-across-melbourne . Please have a good read of the instructions and the blue i-information dots on the page to unearth all the goodies hidden in the map.

Cheers,
Rik

PS: who is Rob?

RdeBoer’s picture

Hi Kevin,
So how did you go on your travels?
Rik